
-
AuthorPosts
-
May 9, 2025 at 9:11 pm #1483946
hello everyone
i have an idea
when i press Ctrl + F the field to search the text on a page appears at the top.is it possible to enter this command (Ctrl + F ) in the content in a line in html so that I can open this command with a mouse click.
Thanks for your info
best regards
FranzMay 10, 2025 at 8:55 am #1483959Hey schweg33,
I’m not sure that I fully understand your intentions, but there is no such functionality in the theme by default unfortunately. If you are looking to implement a custom solution, then you could try searching for similar solutions online to see if anything is available.
Best regards,
RikardMay 10, 2025 at 9:47 am #1483962Directly and reliably opening the browser’s own “Search in page” dialog (typically activated by Ctrl+F or Cmd+F) via an HTML button is generally not possible due to security restrictions and the lack of a standardized web API.
May 10, 2025 at 10:13 am #1483963try this in your child-theme functions.php:
see the better solution on bottom!
May 10, 2025 at 10:38 am #1483964hail brave new AI world
New snippet
see in Action here: https://webers-testseite.de/impressum/this is for child-theme functions.php:
see code here on paste bin: https://pastebin.com/zc4fvX1w
because of a innerHtml (lines 158-176) it is not possible to post it here – (maybe mod knows how)
and here is the style for quick css
/* --- Draggable Search Window --- */ #gcmSearchUIContainer { /* Changed ID for clarity */ position: fixed; top: 100px; /* Initial position from the top */ left: 50%; /* Start horizontally centered */ transform: translateX(-50%); /* Adjust for true centering */ width: 380px; /* A suitable width for a small window */ background-color: #f9f9f9; border: 1px solid #ccc; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.25); z-index: 100001; /* Ensure it's on top, slightly higher than before if needed */ overflow: hidden; /* To contain rounded corners with header */ } #gcmSearchUIContainer.hidden { display: none; } #gcmSearchUIHeader { padding: 10px 15px; background-color: #e8e8e8; border-bottom: 1px solid #ccc; cursor: move; /* Indicates this area is draggable */ border-top-left-radius: 8px; /* Match container's radius */ border-top-right-radius: 8px; /* Match container's radius */ display: flex; justify-content: space-between; align-items: center; } #gcmSearchUIHeader .gcm-title { font-weight: bold; font-size: 1.1em; color: #333; } #gcmSearchUIHeader #gcmCloseSearchBtnDraggable { /* Specific ID for close button in this context */ background: none; border: none; font-size: 1.3em; font-weight: bold; color: #777; cursor: pointer; padding: 0 5px; } #gcmSearchUIHeader #gcmCloseSearchBtnDraggable:hover { color: #000; } #gcmSearchUIBody { padding: 15px; display: flex; flex-direction: column; /* Stack elements vertically */ gap: 10px; /* Space between elements in the body */ } #gcmSearchUIBody #gcmSearchInputDraggable { /* Specific ID for input */ width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } #gcmSearchUIBody .gcm-controls-row { display: flex; justify-content: space-between; /* Space out controls */ align-items: center; gap: 8px; /* Space between buttons in a row */ } #gcmSearchUIBody .gcm-navigation { display: flex; gap: 5px; } #gcmSearchUIBody button { padding: 8px 12px; border: 1px solid #aaa; border-radius: 4px; background-color: #e7e7e7; cursor: pointer; min-width: 40px; /* For Next/Prev buttons */ text-align: center; } #gcmSearchUIBody button:hover { background-color: #d7d7d7; } #gcmSearchUIBody #gcmSearchBtnDraggable { /* Specific ID */ flex-grow: 1; /* Allow Find button to take more space if needed */ } #gcmSearchUIBody .gcm-results-count-draggable { /* Specific ID */ font-size: 0.95em; color: #333; white-space: nowrap; /* Prevent wrapping */ } /* --- Highlighting Styles (remain the same) --- */ .custom-highlight { background-color: yellow; color: black; font-weight: bold; } .custom-highlight.current-custom-highlight { background-color: orange; outline: 1px solid red; }
Do not forget to remove the leading php on that downloaded snippet before you insert it to your child-theme functions.php
Download: https://pastebin.com/dl/zc4fvX1w
May 11, 2025 at 8:18 am #1484007Many thanks Guenni007
Thank you very much for your presentation:
I have now installed everything according to your instructions
Test page: https://wuensche.li/
in the functions.php
and
in the quick css
How do I now make the button appear on the imprint page?Many thanks
Best regards
FrankMay 11, 2025 at 2:03 pm #1484019Hi,
It looks like Guenni007 added a button element with the custom class “my-find-button”.Best regards,
MikeMay 11, 2025 at 4:42 pm #1484027I overlooked this
Sorry Mike, it works great this way
thank you
Guienna007 and Mike
then you can close this request.
best regards
FranzMay 11, 2025 at 8:57 pm #1484040Hello together
I have another question about the script from Guenni007
Now I have added this script to this page:I cannot search for whole names.
For example if I search for “batliner” nothing is found.
but if I abbreviate it to “bat” all batliners are found.Am I doing something wrong
or can this be changed in the script
thanks for your info
Best regards Franz
May 11, 2025 at 10:56 pm #1484048Hi,
Perhaps it has something to do with your language characters, your word Batliner has the HTML entities­
twice in it:
Bat­li­ner
and the script doesn’t seem to be able to read the HTML entities.
I’m not sure if or how this could be fixed, hopefully Guenni007 will have a solution for it.Best regards,
MikeMay 12, 2025 at 7:25 am #1484061Hi Mike
Thanks for your reply
But when I search with Ctr+F, 34 times found appear
Everything is actually found on the https://webers-testseite.de/impressum/
page?
Let’s see if Guienni007 has an idea?Best regards
FranzMay 12, 2025 at 7:52 am #1484064One more addendum:
The problem could be that I have read the table on:with a plugin: Data Tables by Supsystic as a table
If I insert it into html like here:the search works perfectly.
For the plugin I think I have to ask the support of the plugin.
Thanks
Best regards FranzMay 14, 2025 at 6:21 pm #1484250Hi,
Thanks for the updates. Please let us know if you should need any further help.
Best regards,
RikardMay 14, 2025 at 6:37 pm #1484256Thank you very much
Mike and Rikard
Also to Guenni007
You can close this ticket.
Best regards
Franz -
AuthorPosts
- The topic ‘Ctrl + F in html’ is closed to new replies.