Click to See Complete Forum and Search --> : window.open question


cate
04-26-2004, 11:55 AM
Hi,
I'm learning as I go with this one; i've got as far as:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>The Richmond Hill Gallery</title>
<script type="text/javascript">
function openWindow() {
window.open("version2.htm","main","width=785, height=500");
window.close(self);
}
</script>
</head>

<body bgcolor="#000052" onLoad="openWindow();">
&nbsp;
</body>
</html>

so a new window opens and the original closes.
I was wondering whether it was possible to make the new window size go to the maximum size for all screen sizes (instead of a fixed window size), so that its a full screen in all cases, without having to scroll anywhere...
thanks loads!
Cate

Phil Karras
04-26-2004, 12:17 PM
I believe there's a couple of attributes called:

screen.width
and
screen.height

so you would use them like this:

// --------------------------------------------------------------
// Here is where the pop-up windows are created with the "link"
// URL is going to be used.
// --------------------------------------------------------------
if (navigator.appName == 'Microsoft Internet Explorer') { // IE
scw=screen.width-8;
sch=screen.height-147; // full size = -47
alert("IE");
window.open (link, windowName, "left=100,top=10,status=1,width=" + scw + ",height=" + sch);
//window.open (link, windowName); // All the bars but NOT full size
if (navigator.platform == 'MacPPC') {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
}
else if (navigator.appName == 'Netscape') { // NS
scw=screen.width;
sch=screen.height;
alert("NS");
window.open (link, windowName, "screenX=0,screenY=0,status=1,outerWidth=" + scw + ",outerHeight=" + sch);
}
else { // Error message - can not pop open a window.
document.write("<HTML><BODY><CENTER><H1>Get Netscape or Internet Explorer 4.0 or higher</H1></CENTER></BODY></HTML>");
}

Hope that helps.

David Harrison
04-26-2004, 12:26 PM
This code will do what you want but at the price of driving users away, I wouldn't like a fullscreen window opening on me and blocking everything else out.
On browsers with pop-up blockers or without JavaScript enabled the user will see no effect at all,



window.open("version2.htm","main","width=785, height=500,fullscreen=1");

cate
04-26-2004, 12:28 PM
thanks Phil and Lavalamp for replying -
Lavalamp I think you're right - i'm going to stick to the restricted size for the window, but thanks guys for the code - great to learn new things!:)
Cate

David Harrison
04-26-2004, 01:20 PM
Originally posted by cate
i'm going to stick to the restricted size for the windowGood decision. ;)