Added: Jun 11, 2004
Snippet uploaded by: Aaron Campbell
Written By: Aaron Campbell
Demo: Sorry, no demo
This is a simple image popup that opens a new window, that is the right size for the picture. If the window is too big for the users screen, it adjusts. If it has to adjust, it also adjusts the size of the image, so that the user does not need to scroll. it is called like this: openWin(picWidth,picHeight,picName)<br>
//By Aaron D. Campbell
//Feel free to remove these comments
function openWin( winWidth, winHeight, picSrc )
var picWidth = winWidth;
var picHeight = winHeight;
var i = 1;
winWidth = winWidth + 20;
winHeight = winHeight + 100;
if ((screen.availWidth-50) < (winWidth))
winWidth = (screen.availWidth-50);
i = ((winWidth-20)/picWidth);
picWidth = (winWidth-20);
picHeight = (picHeight * i);
if ((screen.availHeight-50) < (winHeight))
i = ((winHeight-100)/picHeight);
picHeight = (winHeight-100);
picWidth = (picWidth * i);
picWidth = Math.round(picWidth);
picHeight = Math.round(picHeight);
newWin = window.open('', '', 'height='+ winHeight + ',width='+ winWidth + 'toolbars=no, scrollbars=no' );
newWin.document.write("<html>n<head>n<title>"+ picSrc +"</title>n</head>n<body background="images/bg.gif">n");
newWin.document.write("<div style="text-align:center; ">n");
newWin.document.write("<img src="" + picSrc + "" width="" + picWidth + "" height="" + picHeight + "">n");
<img src="whatever.jpg" width="xxx" height="xxx" border="0" alt="xxxxx" title="xxxxx" style="cursor:pointer; " onclick="openWin(picWidth,picHeight,'picName.jpg');" />
No Comments to show
Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.
Adding your comment. Please wait...
Thanks for adding your comment!. After further review it will be added.
There was a problem adding your comment. Please try again.
Please complete all the fields in the form before sending.