Lewis Day Lewis Day - 1 year ago 64
Javascript Question

Replace specific words amongst page content with value javascript

I'm trying to replace the word

anywhere on the page with the word
using Javascript. I created the script below however it isn't working how anticipated, is there something that I can do to achieve the outcome desired.

function(data) {
var newdata = data.replace("hello", "hi");


Answer Source

This will work, although might be overkill using regular expressions:

document.body.innerHTML = document.body.innerHTML.replace(/hello/g, "hi")


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download