我可以通过JavaScript以编程方式打开浏览器的本机搜索对话框吗? [英] Can I programmatically open the browser's native search dialogue by JavaScript?

查看:67
本文介绍了我可以通过JavaScript以编程方式打开浏览器的本机搜索对话框吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过编程方式从网页内部打开Web浏览器的本机搜索对话框?

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?

推荐答案

是指浏览器在使用命令触发的页面中进行搜索 + f ctrl + f 取决于您的操作系统

if you mean the browser search inside the page that's triggered using command + f or ctrl + f depending on your OS

,您可以使用 window.find()方法,这是参考

you can use the window.find() method and here is a reference for it,

否则,如果您的意思是包含网站URL的搜索栏,则可以使用 window.location.href 来访问网站的值,以显示当前网址。网址

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;

这篇关于我可以通过JavaScript以编程方式打开浏览器的本机搜索对话框吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆