<html> <head> <title>Untitled</title> </head> <body> <div id='content'> try test try </div> <script> findWord = 'test'; txt = document.body.innerHTML; // document.getElementById('content').innerHTML; while (txt.indexOf(findWord)>=0) txt = txt.replace(findWord, 'REPLACED'); document.body.innerHTML = txt; //document.getElementById('content').innerHTML = txt; </script> </body> </html>