I am new to javascript. I created the below script to replace remove/replace few words in a webpage. It does work but this code also modifies the attributes of html elements. Is there a way to modify only the text contents of html elements and not the html elements' attributes? Here's the code.
var sa=str;
var sal=sa.length;
var tags=document.getElementsByTagName("*");
var tagl=tags.length;
var re;
var ip;
for(var i=0;i<tagl;i++)
{
ip=tags[i].innerHTML;
for(var j=0;j<sal;j++)
{
re=new RegExp(sa[j],'gi');
ip=ip.replace(re,"###");
}
tags[i].innerHTML=ip;
}