Hi peeps,
I have a a large number of pages in which I want to replace parts of links within it. I will give you an example: I have pages that have the following link:
I want to replace the domain www.siteone.com to www.sitetwo.com so that the a href tag to be as shown below:Code:<a href="www.siteone.com/picLib/myPic">My Pic</a>
I need to replace all the links accross a large number of pages. I did use the following javascript code to change all the siteone links to sitetwo:Code:<a href="www.sitetwo.com/picLib/myPic">My Pic</a>
The html body onload tag ran the above script but it changes the whole link instead of part of the link. So the link: www.siteone.com/picLib/myPic will change to www.sitetwo.com instead of www.sitetwo.com/picLib/myPicPHP Code:function fixLinks() {
var replacementURL = "http://www.sitetwo.com"; // URL to change to
var lookfor = "http://www.siteone.com"; // Text to look for
var links = document.getElementsByTagName("a");
for (i=0;i<links.length;i++) {
if (links[i].href.indexOf(lookfor) > -1) links[i].href = replacementURL;
}
}
Any Ideas on how to do this
Thanks,
Ket


Reply With Quote
Bookmarks