Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nermal

Moderator
Original poster
Staff member
Dec 7, 2002
21,427
5,303
New Zealand
I can't get JavaScript's innerHeight function to work in Safari or IE. It works in Firefox - the window's height is set correctly. But Safari and IE seem to ignore the code. Anyone know why it's not working?

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Blah</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript" type="text/javascript">
function setSize() {
self.innerHeight=200;
}
</script>
</head>
<body onload="setSize();">
</body>
</html>
 
IE 5.2 will work with this syntax:

self.document.body.clientHeight = 200;

Safari innerHeight may be read only. I could get the value but setting it doesn't appear to do anything for me, either.

You can try:

self.resizeTo(width, height);

It looks as if you may have to do a little browser sniffing and chose the correct action based on that.
 
According to "JavaScript The Definitive Guide (OReilly)" innerHeight is a proprietary Netscape extension to the Window object. It is probably supported in FireFox as it is based on Mozilla which was mostly developed by Netscape.

As it is not part of any JavaScrip standard I would recommend that you don't use it!

The window.resizeTo(width,height) function might be a better bet? The book does not say if that is the size of the content area or the whole widow, but I think it's the whole window.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.