Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resize pop up window based on image dimensions

Status
Not open for further replies.
Jun 9, 2006
159
US
Hi,

This script resizes the pop up window. There are two problems with it:

Code:
<body leftMargin="0" topMargin="0" style="padding:0px;">
    <form id="form1" runat="server">
    <div>
      
   
       <script language='javascript'>
            function fitPic() {
                if (window.innerWidth){
                    iWidth = window.innerWidth;
                    iHeight = window.innerHeight;
                }else{
                    iWidth = document.body.clientWidth;
                    iHeight =document.body.clientHeight;
                }
                iWidth = document.images[0].width - iWidth;
                iHeight = document.images[0].height - iHeight;
                window.resizeBy(iWidth, iHeight);
            };
        </script>

1) In FireFox there is a left and top margin...
2) In IE, sometimes the height the window resizes to is not the entire image height (sometimes 50%).



Shawn Molloy
Seattle, WA
 
1: Change this:

Code:
<body leftMargin="0" topMargin="0" style="padding:0px;">

to this:

Code:
<body style="padding:0px; margin:0px;">

The attributes "leftmargin" and "topmargin" are not standard, and so are not supported by every browser.

2: What is the image sizde when you notice this behaviour? Some browsers will not let you size a window bigger than the screen dimensions, or smaller than a certain size.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi Dan,

The body style script worked like a charm! It works great in both IE and Firefox.

RE the second issue, that was a bit more difficult to solve. What it turned out to be was that the image that the javascript was reading to determine the width in height was being generated via an http handler (a .NET ashx file). The height and width was passed through params determined at run time and the image was resized and passed into the dom. Since the image was resized IE apparently had an issue reading its height and width attributes, whereas firefox gracefully parsed this information and properly resized the window.

I solved IE's problem by adding the new width and height propery to the image tag. IE most likly looks there first, but not sure why it can't read the outputed resized image.

By the way, your page on CodeCouch has some really amazing and innovative javascripts! Impressive!

Thanks,



Shawn Molloy
Seattle, WA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top