Solved

sizeToContent() for IE

Posted on 2003-10-22
10
1,069 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now