View Single Post
Quote:
Originally Posted by njoy View Post
Thanks for replies. Columbo, could you please tell me step by step. Sorry, my only excuse is that I'm a grandma.
It's really simple:

1) Create a new bookmark (Command-D shortcut)
2) Name that new bookmark
3) Put the following javascript code in the "Address" field:


Code:
javascript:(function(){var%20count=0,%20text,%20dv;text=prompt(%22Search%20phrase:%22,%20%22%22);if(text==null%20||%20text.length==0)return;dv=document.defaultView;function%20searchWithinNode(node,%20te,%20len){var%20pos,%20skip,%20spannode,%20middlebit,%20endbit,%20middleclone;skip=0;if(%20node.nodeType==3%20){pos=node.data.toUpperCase().indexOf(te);if(pos%3E=0){spannode=document.createElement(%22SPAN%22);spannode.style.backgroundColor=%22yellow%22;middlebit=node.splitText(pos);endbit=middlebit.splitText(len);middleclone=middlebit.cloneNode(true);spannode.appendChild(middleclone);middlebit.parentNode.replaceChild(spannode,middlebit);++count;skip=1;}}else%20if(%20node.nodeType==1&&%20node.childNodes%20&&%20node.tagName.toUpperCase()!=%22SCRIPT%22%20&&%20node.tagName.toUpperCase!=%22STYLE%22){for%20(var%20child=0;%20child%20%3C%20node.childNodes.length;%20++child){child=child+searchWithinNode(node.childNodes[child],%20te,%20len);}}return%20skip;}window.status=%22Searching%20for%20'%22+text+%22'...%22;searchWithinNode(document.body,%20text.toUpperCase(),%20text.length);window.status=%22Found%20%22+count+%22%20occurrence%22+(count==1?%22%22:%22s%22)+%22%20of%20'%22+text+%22'.%22;})();
4) Save that newly created bookmark

Just use that bookmark when you want to highlight all matches of a word.