...

View Full Version : Resize Popup that Fits an Image Size



m7d7g7
08-25-2004, 03:20 PM
Hi, i just recently found this tutorial on how to make a neat photogallery:

http://asp-hosting.ca/faq/Resize-a-Popup-to-Fit-an-Image-Size-in-JavaScript.htm


it automatically resizes a window to fit around an image. but when i tried it out, some of windows resize around the picture right, and some of them resize a 200x200 box. I was wondering if there was something wrong with the script?

Thanks,
Mike.

Willy Duitt
08-27-2004, 01:05 AM
Hard to say without looking at how you implemented the script but if you search this forum for image popup I'm sure you will find much better examples which should be easier to implement....

.....Willy

m7d7g7
08-27-2004, 03:09 AM
thanks.

jbot
08-27-2004, 10:39 AM
for Mozilla only: window.sizeToContent() (http://www.faqts.com/knowledge_base/view.phtml/aid/7567)

jamescover
08-27-2004, 08:38 PM
<script>
<!--

function newWin(picName,winName,w,h,top,left){

var largePic = window.open('',winName,'width='+w+',height='+h+',top='+((screen.height-h)/2)+',left='+((screen.width-w)/2));

var markup = ('<html>\n<head>\n<title>largePic<\/title>\n<\/head>\n<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="javascript:self.focus()">\n<img src="'+picName+'" border="0" width="'+w+'" height="'+h+'" alt="'+picName+'" onclick="javascript:self.close();" style="cursor:pointer;" />\n<\/body>\n<\/html>');

largePic.document.open();
largePic.document.write(markup);
largePic.document.close();
}

//-->
</script>


<img src="nameOfThumb.gif" width="50" height="50" alt="nameOfThumb.gif" border="0" onclick="javascript:newWin('nameOfLargeImage.gif','myWin1','300','300','top','left');" style="cursor:pointer;" />


-james

jamescover
08-27-2004, 10:49 PM
I added a little title bar animation:



<script>
<!--

function newWin(picName,winName,w,h,top,left){

var largePic = window.open('',winName,'status=yes,width='+w+',height='+h+',top='+((screen.height-h)/5)+',left='+((screen.width-w)/2.1));

var markup = ('<html>\n<head>\n<title>largePic<\/title>\n<script type="text\/javascript">\n<!--\n\nx = 0;\ndoc = document;\n\nfunction getCnt(){\nif(doc.images[0].complete){\nclearInterval(setInv);\ndoc.title = "Download Complete!";\n}else{\ndoc.title = "Loading: [" + x + "]";\nx++;\n}\n}\nvar setInv = setInterval(getCnt,10);\n\n\/\/-->\n<\/script>\n<\/head>\n<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="javascript:self.focus()">\n<img src="'+picName+'" border="0" width="'+w+'" height="'+h+'" alt="'+picName+'" onclick="javascript:self.close();" style="cursor:pointer;" />\n<\/body>\n<\/html>');

largePic.document.open();
largePic.document.write(markup);
largePic.document.close();
}

//-->
</script>


<img src="nameOfThumb.gif" width="50" height="50" alt="nameOfThumb.gif" border="0" onclick="javascript:newWin('nameOfLargePic.gif','myWin1','640','480','top','left');" style="cursor:pointer;" />



-james



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum