faqts : Computers : Programming : Languages : JavaScript : Windows

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 15 people (87%) answered Yes
Recently 6 of 7 people (86%) answered Yes

Entry

How can I size a window to its content's size?

Feb 3rd, 2001 03:53
Martin Honnen,


NN6/Mozilla has introduced the method
  sizeToContent
of the
  window
object. Unfortunately it works sometimes and sometimes not.
Here is an exampe use that demonstrates the problem
<HTML>
<HEAD>
</HEAD>
<BODY ONLOAD="window.sizeToContent(); setTimeout('location.reload()', 
3000)">
<SCRIPT>
var w = Math.floor(Math.random() * (screen.width - 150)) + 100;
var h = Math.floor(Math.random() * (screen.height - 250)) + 100;
document.write('<IMG 
SRC="http://www.mozilla.org/images/mozilla-banner.gif" WIDTH="' + w + '" 
HEIGHT="' + h + '">');
</SCRIPT>
</BODY>
</HTML>
The bug at bugzilla for the problem is
  http://bugzilla.mozilla.org/show_bug.cgi?id=67546