Rarely willing to give up all that easily, even though it is likely to have problems in some browsers and in any browser with large images and a small screen. I came up with this method that isn't too horrible:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Image Opener - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function open_image(im){
if(!document.images)
return true;
if(open_image.nwin&&open_image.nwin.open)
open_image.nwin.close();
var l=screen.availWidth||0, t=screen.availHeight||0;
open_image.nwin=window.open('','','resizable, width=300, height=300'+(l? ',top='+[t/2-150]+',left='+[l/2-150] : ''));
open_image.nwin.document.write('<title>'+unescape(im.replace(/.*\/([^/]*)/,'$1'))+'<\/title>\n'+
'<script type="text/javascript">\n'+
'onload=function(){\n'+
'window.resizeTo(300,300);\n'+
'var nim=new Image(),l=screen.availWidth||0, t=screen.availHeight||0;\n'+
'var dw=window.innerWidth? 300-window.innerWidth : 300-document.body.clientWidth;\n'+
'var dh=window.innerHeight? 300-window.innerHeight : 300-document.body.clientHeight;\n'+
'nim.onload=function(){\n'+
'window.resizeTo(nim.width+dw, nim.height+dh);\n'+
'if(l)\n'+
'window.moveTo(l/2-(nim.width+dw)/2, t/2-(nim.height+dh)/2);\n'+
'document.images[0].style.visibility=""\n'+
'}\n'+
'nim.src="'+im+'";\n'+
'}\n'+
'<\/script>\n'+
'<body style="margin:0;padding:0;"><img style="visibility:hidden;" src="'+im+'">');
open_image.nwin.document.close();
return false;
}
onunload=function(){
if(open_image.nwin&&open_image.nwin.open)
open_image.nwin.close();
}
</script>
</head>
<body>
<h2>Images In this Demo © 2007 loisimages.com</h2>
<a href="http://loisimages.com/Eyes_Trees%20in%20smoke1_400_optimized.jpg" onclick="return open_image(this.href);">Eye</a><br>
<a href="http://loisimages.com/blue_elephant3_400_optimized.jpg" onclick="return open_image(this.href);">Elephant</a><br>
<a href="http://loisimages.com/dog_tongue_out_400_optimized.jpg" onclick="return open_image(this.href);">Tongue</a><br>
</body>
</html>
Bookmarks