Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2002
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Resize Popup that Fits an Image Size

    Hi, i just recently found this tutorial on how to make a neat photogallery:

    http://asp-hosting.ca/faq/Resize-a-P...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.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    New Coder
    Join Date
    Oct 2002
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks.

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    for Mozilla only: window.sizeToContent()
    *keep it simple (TM)

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <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
    Last edited by jamescover; 08-28-2004 at 01:00 AM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #6
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I added a little title bar animation:


    Code:
    <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
    Last edited by jamescover; 08-28-2004 at 01:01 AM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •