I have a site that is under development and it was made really badly so I needed a quick way to replace all anchors on page to the relevant path.

The problem is because it was a testsite that lived away from the public facing domain, the anchors had to be changed because they were all coded in as absolute paths.

I included a JavascriptDebug file and put the following in there:

[code lang=”javascript”]
function replaceAnchorsTestSite(){
var allAnchors = document.getElementsByTagName(“a”);
var string1 = “http://***.***.***.***/testsite/”;
var string2 = “http://***.***.***.***/”;
for (var i=0; i

1 Comment

stone · April 19, 2013 at 12:43

thank you so much, you save my time, really 🙂

Have a nice weekend.

Leave a Reply

Your email address will not be published.

%d bloggers like this: