简体   繁体   中英

How to keep old highlights when calling window.find() again

If I use the below code I am able to highlight the found text in Window.

 window.find(str);

But if I search for another string with window.find() the previous highlight will be removed. But how can I change that to not remove old highlights..

You can use document.execCommand() to add styling to the current selection after calling window.find() . See my answer here, for example:

https://stackoverflow.com/q/5887719/96100

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM