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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    scrollbars in popup window with firefox

    The following script opens a popup for an image and it is supposed to determine the size of the image and size the window accordingly. In IE, it works fine...in Firefox, scrollbars appear. Is there a fix?

    Code:
    function popImg(which){
       var theImg = new Image();
           theImg.src = which;
       var imgw = theImg.width;
       var imgh = theImg.height;
    
        if(imgw<473){imgw = 473};
        if(imgh<214){imgh = 214};
    
         var imgWin = window.open('','popImg',config='height='+imgh+
                                     ',width='+imgw+',top=0,left=100');
           with(imgWin.document){
            writeln('<html><head><title>Saturn of Harrisonburg</title></head>');
            writeln('<body onload="self.focus()" onblur="self.close()">');
            writeln('<div style="position:absolute;top:0;left:0;text-align:center">');
            writeln('<a href="#" onClick="self.close()" onMouseOver="this.style.cursor=\'hand\'; window.status = \'Close Window\'; return true;" onMouseOut="window.status = \'\'; return true;"><img src='+which+' alt="" width="473" height="214" border="0"></a></div>');
            writeln('<div style="text-align:center;font-size:9px">');
            writeln('<a href="#" onClick="self.close()" onMouseOver="this.style.cursor=\'hand\'; window.status = \'Close Window\'; return true;" onMouseOut="window.status = \'\'; return true;">Close Window</a>');
            writeln('</div></body></html>');
            close();
           }
      }

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by AshleyQuick
    The following script opens a popup for an image and it is supposed to determine the size of the image and size the window accordingly. In IE, it works fine...in Firefox, scrollbars appear. Is there a fix?

    Code:
    function popImg(which){
       var theImg = new Image();
           theImg.src = which;
       var imgw = theImg.width;
       var imgh = theImg.height;
    
        if(imgw<473){imgw = 473};
        if(imgh<214){imgh = 214};
    
         var imgWin = window.open('','popImg',config='height='+imgh+
                                     ',width='+imgw+',top=0,left=100');
           with(imgWin.document){
            writeln('<html><head><title>Saturn of Harrisonburg</title></head>');
            writeln('<body onload="self.focus()" onblur="self.close()">');
            writeln('<div style="position:absolute;top:0;left:0;text-align:center">');
            writeln('<a href="#" onClick="self.close()" onMouseOver="this.style.cursor=\'hand\'; window.status = \'Close Window\'; return true;" onMouseOut="window.status = \'\'; return true;"><img src='+which+' alt="" width="473" height="214" border="0"></a></div>');
            writeln('<div style="text-align:center;font-size:9px">');
            writeln('<a href="#" onClick="self.close()" onMouseOver="this.style.cursor=\'hand\'; window.status = \'Close Window\'; return true;" onMouseOut="window.status = \'\'; return true;">Close Window</a>');
            writeln('</div></body></html>');
            close();
           }
      }
    Try removing the margins and boders from the body, divisions and image tags...
    Or, try using the image as a body background, not an img src....

    .....Willy


  •  

    Posting Permissions

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