Highlight word in HTML Page

Talk about add-ons and extension development.
Post Reply
gaurangnshah
Posts: 3
Joined: September 4th, 2017, 4:01 am

Highlight word in HTML Page

Post by gaurangnshah »

hi Guys,

I was updating my firefox-on which highlights few words based on some process. However. as Firefox has change few things, it no longer allow to directly update the body content of the webpage.

I get following error.

Code: Select all

Markup should not be passed to `innerHTML` dynamically.
Warning: Due to both security and performance concerns, innerHTML may not be set using dynamic values which have not been adequately sanitized. This can lead to security issues or fairly serious performance degradation.

chrome/content/checkWebpage.js
//alert(bodyContents);
vrs_getWin.document.getElementsByTagName("body")[0].innerHTML = bodyContents;


Does anyone know if there is an in-built api to highlight words in HTML. I don't know the id of the node so I can't append any child node to that, I only know word by it's text.
Post Reply