问题
Is it possible to programmatically open the web browser's native search dialogue from inside a web page?
And more over, if it's possible, can I programmatically perform a search inside of it?
回答1:
if you mean the browser search inside the page that's triggered using command
+ f
or ctrl
+ f
depending on your OS
you can use the window.find()
method and here is a reference for it,
otherwise, if you mean the search bar which contains the URL of the website you can access its value by using window.location.href
which will present the current URL
and if you want to do some search you can easily change it to anything just by typing
window.location.href = your_value;
来源:https://stackoverflow.com/questions/52835530/can-i-programmatically-open-the-browsers-native-search-dialogue-by-javascript