For example if I have a web page HTML like below
<body>
Hello Techies, <br>
Techies here.
</body>
If I search for “Techies” using
var sel = window.getSelection();
sel.collapse(document.body, 0);
document.body.offsetHeight;
if (window.find("Techies", true)) {
document.execCommand("hiliteColor", false, "YellowGreen");
sel.collapseToEnd();
}
It is Highlighting only the first occurred of the “Techies”. But when I search with Ctrl+F the first occurrence will be highlighted in Dark and next occurrences will be highlighted in light color mode. How can I achieve the same with the above code.
Try using a
whileloop: