[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1119
  • Last Modified:

sizeToContent() for IE

I need to size the window to the content of the document, which is only an image smaller than 800x600 to fit in standar monitors.

NN has a function called "sizetoContent()" determines the optimum window size to display the window content, how can I do the same but for IE browsers?
0
mltolun
Asked:
mltolun
  • 5
  • 3
1 Solution
 
ahosangCommented:
The relevant part being this:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function openemh(bigSrc) {// the parameter is the url of the large version of the thumbnail
   newwin = window.open("","blah","resizable=no,width=600,height=200");
   var str="<html><head><title>EmilyHorridge.com - photo</title>";
   str+="<scri"+"pt>if (!window.sizeToContent) {function sizeToContent(img) {\n";
   str+="x=img.width;y=img.height;\n";
   str+="window.resizeTo(x, y);}}</scr"+"ipt>";
   str+="</head><body topmargin='0' leftmargin='0'>";
   str+="<img src=\""+bigSrc+"\" border=\"0\" onload=\"sizeToContent(this)\"></body></html>";
   newwin.document.write(str);
   newwin.document.close();
}
// -->
</script>
</head>
<body>
<a href="#" onClick="openemh('http://www.emilyhorridge.com/images/Gallery/Abercarn1.jpg');return false">
<img name="img1" src="http://www.emilyhorridge.com/images/gallery_thumbs/Abercarn1.jpg" width="85" height="85" border="0"></a>
</body>
</html>
0
 
ahosangCommented:
Is this helping you?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
mltolunAuthor Commented:
ummm....I'm not sure...
The "window.resizeTo" function does not resize to the content. It includes the title bar in the height value.
If my pic has 80px of height and I use the "resizeTo" function with 80px value for the height and the title bar is 20px, only 60px of my pic will be shown.
0
 
ahosangCommented:
Yes, in that thread there was the discussion of the fact that you must make a small adjustment to the x an y values. It should work perfectly on Mozilla, but IE needs a small adjustment.
0
 
mltolunAuthor Commented:
But the title bar height can vary. In my windows has 20px....but in a friends windows has 30px...so...
I need to forget about the title bar, and only size the content.
Or know the title heigh and add it to the height parameter.
0
 
mltolunAuthor Commented:
SO??
hi?
0
 
ahosangCommented:
There is no exact way to know what the heights of these browser components are. In IE the window can be sized the way I showed you, so maybe better to oversize it, or open a new window with no title bars or toolbars as I did in that code above.
0
 
jaysolomonCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: ahosang {http:#9602294}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now