View Full Version : word replace
02-21-2003, 08:47 PM
how do you tell a page to replace a certin word with another specified word everywhere its listed on the page. I don't mean like find and replace I mean like at run time.
02-21-2003, 09:15 PM
Quick & dirty way
function replaceWord( word, replacment )
var pattern = new RegExp( word, "i" );
document.body.innerHTML = document.body.innerHTML.replace( pattern, replacement );
02-22-2003, 03:43 AM
Best off doing this server-side before the page is returned to the client in many cases - but of course, that depends on your purpose. Which is?
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.