<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Demo</title>
</head>
<body>
<p><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/7/79/Face-smile.svg/48px-Face-smile.svg.png" alt="Image"></p>
<p><img src="http://upload.wikimedia.org/wikipedia/commons/1/1d/HP1_template.gif" alt="Image"></p>
<p><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Astronaut-EVA.jpg/48px-Astronaut-EVA.jpg" alt="Image"></p>
<p><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/Check.svg/48px-Check.svg.png" alt="Image"></p>
<p><img src="http://upload.wikimedia.org/wikipedia/commons/1/1a/Schackbr%C3%A4de_MVS.jpg" alt="Image"></p>
<script type="text/javascript">
/*<![CDATA[*/
var imgs = document.getElementsByTagName('img');
var jpg = null;
for(var i=0;i<imgs.length;i++) {
if((imgs[i].src.toLowerCase().substr(-5) == '.jpeg') || (imgs[i].src.toLowerCase().substr(-4) == '.jpg')) {
jpg=imgs[i].src;
break;
}
}
if(jpg) alert(jpg);
else alert('No JPEG was found.');
/*]]>*/
</script>
</body>
</html>
|