Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sizeToContent() for IE

Posted on 2003-10-22
10
Medium Priority
?
1,112 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
10 Comments
 
LVL 12

Expert Comment

by:ahosang
ID: 9602279
0
 
LVL 12

Accepted Solution

by:
ahosang earned 400 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
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.

 

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

636 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