Alex Rivera | Logout

Find all instances of 'old' in a webpage and replace each with 'new', using a javascript bookmarklet

Asked 2009-07-24T04:43:22.537
15

What I want to do is replace all instances of 'old' in a webpage with 'new' in a JS bookmarklet or a greasemonkey script. How can I do this? I suppose jQuery or other frameworks are okay, as there're hacks to include them in both bookmarklets as well as greasemonkey scripts.

Edit
Report

1 Answer

-1

Hey you could try this, problem is it searches the entire body so even attributes and such get changed.

javascript:document.body.innerHTML=document.body.innerHTML.replace( /old/g, "new" );
answered 2009-07-24T04:52:21.067

Your Answer