
Originally Posted by
mburt
screen.availWidth/height varies between browsers. In IE, the height overlaps the actual screen height.

Originally Posted by
boxxertrumps
I see...
I didn't really expect it to, but i had thought JS could use percents like that.
Yeah, that was mostly what I meant by the fixable part. The thing about IE and screen.availWidth/Height is that IE calculates that before it decides what chrome to assign to the window. So, it adds the chrome (title and scroll bars, etc.) onto those dimensions.
Now, you cannot access the window size across domains but, if you are only launching your own page:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function winopen(url){
var h=screen.availHeight, w=screen.availWidth;
var win=window.open(url,'','statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,top=0,left=0,width='+w+',height='+h);
try{
win.resizeTo(w,h);
}
catch(e){
}
return false;
}
</script>
</head>
<body>
<a href="some.htm" onclick="return winopen(this.href);">G</a>
</body>
</html>
will work out. Legacy browsers will barf on try/catch. There are ways to prevent that but, if this is only done locally to open a local page, or with pages on the same domain, it really isn't needed:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function winopen(url){
var h=screen.availHeight, w=screen.availWidth;
var win=window.open(url,'','statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,top=0,left=0,width='+w+',height='+h);
win.resizeTo(w,h);
return false;
}
</script>
</head>
<body>
<a href="some.htm" onclick="return winopen(this.href);">G</a>
</body>
</html>
Bookmarks