Javascript to change extensions to jpg

by trichophile

Here is a javascript that will simplemindedly change all extensions to jpg, so you will get red X boxes for any links that don't have a corresponding jpg file, but that shouldn't hurt. It won't work if the correct extension would be JPG instead of jpg, but if you run into that situation, just change jpg to JPG in the script. It would be nicer to eliminate extensions like com and net that obviously don't correspond to a jpg file, but it's a pain to pack so much code on to a single line.


javascript: l = document.links; v = ""; for (i = ; i < l.length; i++) v += '<img src=' + l[i].href.replace(/.[^.]+$/,'.jpg') + '>'; v;


I used html character entitites above to display angle and square brackets. Hope that works.