Hello JavaScript guru's. I have a simple JS question on how to replace all IMG src path's on a page.
Currently, my IMG tags look like:
<img src="path/to/image.jpg" alt="" />
Output desired:
<img src="../image.jpg" alt="" />
So, when a page is loaded, it will loop through all the IMG tags and replace the SRC path. Thanks in advance for the assistance!
for (var image, src, images = document.images, l=images.length, i=0; i<l; i++){
image = images[i];
src = image.src;
image.src = ".." + src.substring(src.lastIndexOf("/"));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With