SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard jag5311's Avatar
    Join Date
    Jan 2003
    Location
    Somewhere in Indiana
    Posts
    3,082
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic image popup script

    I am looking for a solid script that will allow me to popup an image in a window that is the proper height and width of the image. The height and width values need to be generated dynamically based on the image being called

    I am using one right now and it works, but someone told me the code isn't very good.

    Code:
      function viewPic(img)
     {       
         picfile = new Image(); 
         picfile.src =(img); 
         fileCheck(img); 
     }
     function fileCheck(img)
     {       
         if( (picfile.width!=0) && (picfile.height!=0) )
         { 
             makeWindow(img); 
         }
     }
     function makeWindow(img)
     {       
         ht = picfile.height + 18;
         wd = picfile.width + 18; 
     
         var args= "height=" + ht + ",innerHeight=" + ht;
         args += ",width=" + wd + ",innerWidth=" + wd;
         if (window.screen) 
         { 
             var avht = screen.availHeight; 
             var avwd = screen.availWidth;
             var xcen = (avwd - wd) / 2; 
             var ycen = (avht - ht) / 2;
             args += ",left=" + xcen + ",screenX=" + xcen;
             args += ",top=" + ycen + ",screenY=" + ycen + ",resizable=yes";         
         }
         return window.open(img, '', args); 
     }
    Thanks

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I presume that you want a title bar
    if so have a look at


    http://www.vicsjavascripts.org.uk/Im...ImagePopUp.htm


Bookmarks

Posting Permissions

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