Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a method to use Javascript or jQuery to launch Chrome Find? (Same as ctrl + f)?

I'm working on an extension and rather than build my own search functionality, I'd rather just use Chrome's for searching a page for text. Is there a way to create a button that says "Search" and when clicked will be the same as a CTRL + F keypress by the user?

I apologize if this is a redundant question. I didn't succeed in finding it here already.

like image 460
Korak Avatar asked Apr 28 '11 21:04

Korak


People also ask

How do you implement Ctrl F?

If you're in a document or in a web browser, pressing the Ctrl key + the F key will bring up a search box in the top right corner of the screen. You can then type in a keyword or phrase to find places where that word or phrase is used in the text, often helpful for locating relevant sections.

Does browser understand jQuery?

Browsers 'understand' JavaScript because it is built in. JavaScript understands jQuery because it is, after all, JavaScript under the hood, not a separate, discrete language. It is JS.

How do I view JavaScript files in Chrome?

Chrome. Open Chrome and navigate to the web page containing the JavaScript you want to view. Right-click an empty area on the web page and select Inspect in the pop-up menu to open the Chrome developer tools.


1 Answers

https://developer.mozilla.org/en/DOM/window.find

Testing test

<form onsubmit="window.find(this.q.value,false,true,true,true,false,true); return false">
<input id="q" type="text" value="test" />
<input type="submit" value="Find" />
</form>


Testing test

Note: I could only make this do a find BEFORE (or after if set to search backwards) the input field for some reason

Update: Had a quick google and this showed up: https://github.com/philc/vimium/wiki/Chromium-bugs-we%27re-tracking

like image 69
mplungjan Avatar answered Nov 15 '22 02:11

mplungjan