Solved

sizeToContent() for IE

Posted on 2003-10-22
10
1,092 Views
Last Modified: 2010-05-18
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
Comment
Question by:mltolun
  • 5
  • 3
10 Comments
 
LVL 12

Expert Comment

by:ahosang
ID: 9602279
0
 
LVL 12

Accepted Solution

by:
ahosang earned 100 total points
ID: 9602294
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
 
LVL 12

Expert Comment

by:ahosang
ID: 9633177
Is this helping you?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mltolun
ID: 9641775
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
 
LVL 12

Expert Comment

by:ahosang
ID: 9643000
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
 

Author Comment

by:mltolun
ID: 9644993
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
 

Author Comment

by:mltolun
ID: 9711836
SO??
hi?
0
 
LVL 12

Expert Comment

by:ahosang
ID: 9714385
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
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10345841
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question