使用浏览器搜索(Ctrl+F)通过一个按钮在网站上?

时间:2022-12-01 14:06:22

I have created a website and have added a button and lot of text. What I want is to use the browser search (Ctrl+F), when I press the button which I added in website.

我创建了一个网站,并添加了一个按钮和许多文本。我想要的是使用浏览器搜索(Ctrl+F),当我点击网站中添加的按钮时。

How can I achieve this?

我如何做到这一点?

3 个解决方案

#1


14  

It kind of works for FF. See this page

这对FF来说是可行的。看到这个页面

 <a href="#" onclick="find();">Find in This Page...</a>

#2


12  

update: from mark's comment:

更新:从马克的评论:

From my testing window.find() is supported in Chrome 37, and FF31, but not IE11

在我的测试窗口中,find()支持Chrome 37和FF31,但不支持IE11

update:

更新:

for more information on this window.find go here

有关此窗口的更多信息。找到去这里

#3


6  

No. In general, you cannot invoke browser controls from inside the webpage - security, sandboxing, and all that.

不。一般来说,您不能从网页内调用浏览器控件——安全性、沙箱,等等。

You need to make some sort of in-page search - if you're using a CMS, most of them have a simple search feature built-in.

你需要做一些页面内搜索——如果你使用的是CMS,大多数都内置了一个简单的搜索功能。

If you want to do this in JavaScript, there are various scripts that emulate this in-page; randomly selected from my query "javascript find in page" is this one: http://www.seabreezecomputers.com/tips/find.htm

如果想在JavaScript中实现这一点,可以使用各种脚本来模拟这个页面;从我的查询“javascript在页面中找到”中随机选择的是这个:http://www.seabreezecomputers.com/tips/find.htm

#1


14  

It kind of works for FF. See this page

这对FF来说是可行的。看到这个页面

 <a href="#" onclick="find();">Find in This Page...</a>

#2


12  

update: from mark's comment:

更新:从马克的评论:

From my testing window.find() is supported in Chrome 37, and FF31, but not IE11

在我的测试窗口中,find()支持Chrome 37和FF31,但不支持IE11

update:

更新:

for more information on this window.find go here

有关此窗口的更多信息。找到去这里

#3


6  

No. In general, you cannot invoke browser controls from inside the webpage - security, sandboxing, and all that.

不。一般来说,您不能从网页内调用浏览器控件——安全性、沙箱,等等。

You need to make some sort of in-page search - if you're using a CMS, most of them have a simple search feature built-in.

你需要做一些页面内搜索——如果你使用的是CMS,大多数都内置了一个简单的搜索功能。

If you want to do this in JavaScript, there are various scripts that emulate this in-page; randomly selected from my query "javascript find in page" is this one: http://www.seabreezecomputers.com/tips/find.htm

如果想在JavaScript中实现这一点,可以使用各种脚本来模拟这个页面;从我的查询“javascript在页面中找到”中随机选择的是这个:http://www.seabreezecomputers.com/tips/find.htm