PDA

Click to See Complete Forum and Search --> : Windows Size Not Screen Size


Ramandeep
May 18th, 2001, 05:14 PM
How can I get the current windows size. I want to centre a windows when it displays, currently I developed the following method but I have to put the window size in myself, I want it to be able to retrieve the current windows size automatically.


<script language="JavaScript">
self.resizeTo(640,480)

xWidth = ( screen.availWidth - 640 ) / 2;
yHeight = ( screen.availHeight - 480 ) / 2;

self.moveTo(xWidth,yHeight)
</script>

scoutt
May 21st, 2001, 06:38 PM
how about this? works in IE3 and NS3

<html>
<head>
<title>Centered pop-up window</title>

<SCRIPT LANGUAGE="JavaScript" type="text/Javascript">
function popUpCenteredWindow() {
var iMyWidth;
var iMyHeight;
//gets top and left positions based on user's resolution so hint window is centered.
iMyWidth = (window.screen.width/2) - (122 + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
iMyHeight = (window.screen.height/2) - (27 + 50); //half the screen height minus half the new window height (plus title and status bars).
var win2 = window.open("","Window2","status,height=55,width=245,resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");
win2.focus();
}
</SCRIPT>
</head>

<body>
<A HREF="javascript:void(0);" onClick="popUpCenteredWindow();">open a new window centered on the screen regardless of user's resolution.
</A>

</body>
</html>

sail3005
May 22nd, 2001, 04:20 PM
Cool, thanks, i have been looking for that for a long time!

scoutt
May 22nd, 2001, 04:29 PM
no problem, I'm just glad someone around here knows how to appreciate someone else's help and says thank you. I have answered a few posts and the guy doesn't respond with anything like thanks or that don't work. So I don't know if I am helping or not. maybe I'll just stop helping people that don't appreciate these forums.

sail3005
May 22nd, 2001, 04:41 PM
Some people get mad when people do simple "thank you" posts because it adds to their post count when they didn't really answer a question. I don't really care though, because i am not answering questions for my health. I like to know when i helped someone, and i like to know when someone helped me. Who cares what the post count is!

scoutt
May 22nd, 2001, 05:34 PM
exactly!! :D