AaronCampbell
07-14-2004, 06:41 PM
Ok, I made this script a while ago. It is used to open a window with a full-size picture, when a thumbnail is clicked. IF the pic is too big to fit on the users screen, it should adjust the width & height args to show the whole image. I can't figure out why, when the popup opens, it never stops loading. I get the little arrow/hourglass cursor forever. Also, with a pic that is: 4482x2988, it DOES seem to adjust the size (I can't view the source until it loads all the way, and it's not loading all the way, so I don't know HOW much it adjusts), but it still needs to scroll left & right.
Anyway, here is the code: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)){
winHeight= (screen.availHeight-50);
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.writeln("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
newWin.document.writeln("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
newWin.document.writeln("<head>");
newWin.document.writeln("<title>"+ picSrc +"</title>");
newWin.document.writeln("</head>");
newWin.document.writeln("<body>");
newWin.document.write("<div style=\"text-align:center; \">\n");
newWin.document.write("<img src=\"" + picSrc + "\" width=\"" + picWidth + "\" height=\"" + picHeight + "\" border=\"1\" />\n");
newWin.document.write("<br />\n<br />\n<input type='button' value='Close' onclick='javascript:window.close();'>\n</div>\n");
newWin.document.write("</body>\n</html>");
}
Anyway, here is the code: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)){
winHeight= (screen.availHeight-50);
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.writeln("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
newWin.document.writeln("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
newWin.document.writeln("<head>");
newWin.document.writeln("<title>"+ picSrc +"</title>");
newWin.document.writeln("</head>");
newWin.document.writeln("<body>");
newWin.document.write("<div style=\"text-align:center; \">\n");
newWin.document.write("<img src=\"" + picSrc + "\" width=\"" + picWidth + "\" height=\"" + picHeight + "\" border=\"1\" />\n");
newWin.document.write("<br />\n<br />\n<input type='button' value='Close' onclick='javascript:window.close();'>\n</div>\n");
newWin.document.write("</body>\n</html>");
}