![]() |
I'm having trouble changing links in a page. For example on this page - http://forum.weatherzone.com.au/ubbthreads.php/... I would like to convert the link "radar" in the user's post to plain text. (function(){
}
})(); I've tried the above simple replace, but I've clearly missed something very basic and presumably quite important. Can anyone please give me a clue as to where I'm going wrong? |
![]() ![]() |
Well, I'm not entirely sure, but it seems like there are certain things in the script that shouldn't be there.
if (radarlink != null)
}
})(); For instance, just before the word "function", there's an open (, whose purpose seems beyond me at this point, aswell one at the end, along with an additional (); that seems like it serves no purpose either. Unless there is more to your script than what I'm seeing here, that might be part of the issue. |
![]() |
Thanks for your reply. I found the problem. It seems like replace() was treating the strings as mangled regexes for some reason. I escaped the slashes and it's working properly now. |
![]() ![]() |
Modyfing innerHTML of body isn't a very good idea. Since you know exactly the url of a link why not replace it:
link = document.querySelector('a[href="http://www.weatherzone.com.au/radar/"]');
if (link != null)
link.parentNode.replaceChild(document.createTextNode("radar"), link);
|

