Can I programmatically open the browser's native search dialogue by JavaScript?

邮差的信 提交于 2020-07-06 17:42:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!