In some forum I join, they just replace some link with something like spam or deleted. Example: http://www.rapidshare.com/download/123 will automatically turn to http://www.spam.com/download/123 OR word MONEY will change to BOSS.
Its really annoyed me because I have to rename back manually if I want to download. Is there any Javascript that can solve this that will replace back http://www.spam.com to http://www.rapidshare.com? I mean in client side.
Thanks
If these URLs are in
hrefattributes…Your usage may be something like…
If these URLs are inline text…
You could iterate over all text nodes, using
replace()to replace any string with another.Here is a general purpose recursive function I’ve written to do this…
Your usage may be something like…
If you are curious as to how the code works, here is a brief explanation…
element. This will get text nodes and elements.elementas theelementin the loop.continuebecause we can’t modify this as it is not a text node.nodeTypeproperty is not3(i.e. a text node), thencontinueas again we can’t modify any text.You could make this function more flexible by passing
searchstraight to it, allowing it to search for text using a string or a regular expression.