开发者

Create Safari's Find Function Style Text Selector in Javascript

开发者 https://www.devze.com 2023-03-13 01:00 出处:网络
Is there any way开发者_StackOverflow to make this text selection effect easily with a library in Javascript? It is very well done and I\'d like to mirror this look.

Is there any way开发者_StackOverflow to make this text selection effect easily with a library in Javascript? It is very well done and I'd like to mirror this look.

Wondering if anyone had done something similar or seen it done before and if they could provide any guidance. Thanks!

Create Safari's Find Function Style Text Selector in Javascript


  • on-page text highlighting Search with jQuery and
  • On-Page Text Search.

The style is quite similar to the Safari implementation.


You can use window.find() in most browsers and TextRange's findText() method in IE to find all occurrences of a particular string in the page, and then use execCommand() to style each occurrence. See Full text search in HTML ignoring tags / & for an example. This won't give you the curvy corners and drop shadow but is a starting point. It also doesn't work in Opera.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号