dauyeung
asked on
How do you replace a URL in an "IMG" tag with Javascript
I moved a website and the images are no longer at the same URL, but I don't want to manually change all the pages on the website. I'd like to write some javascript to add to the page to change all instances of the URL in the image tag, since I can easily add the code across the entire website.
Old Site IMG Tag
Desired New Site IMG Tag
Basically, I need to change www.domain.com to files.domain.com
Old Site IMG Tag
<img alt="" src="http://www.domain.com/entertainment/music/2007/images/04.000.jpg" width="270" align="left" border="0" id="exifviewer-img-1" exifid="-2145830154" oldsrc="http://www.domain.com/entertainment/music/2007/images/04.000.jpg">
Desired New Site IMG Tag
<img alt="" src="http://files.domain.com/entertainment/music/2007/images/04.000.jpg" width="270" align="left" border="0" id="exifviewer-img-1" exifid="-2145830154" oldsrc="http://files.domain.com/entertainment/music/2007/images/04.000.jpg">
Basically, I need to change www.domain.com to files.domain.com
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.