Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Collecting window dimensions


Message #1 by "Kev Fields" <drunkendruid@h...> on Sat, 6 Oct 2001 11:10:55 -0400
Yeah, a pop-up window. Not an alert window, or confirm window though.
I have a working version, but it uses a fixed-sized window.
But what I was looking for was a way to find the size (being the height 
and width) of the pop-up window.

Below is the script that I was talking about.

*BEGIN SNIPPET*

  <script language="javascript">
   <!--
   var screenWidth, screenHeight;
   var myHeight = 480;
   var myWidth = 640;

   function windowLoad()
     {
     var theWindow = window.open("blank.html", "", "height=" + myHeight 
+ ", width=" + myWidth + "");
     moveWindow(theWindow);
     }

   function findScreenRes()
     {
     var screenInfo = parent.screen;

     screenWidth = screenInfo.width;
     screenHeight = screenInfo.height;
     }

  function moveWindow(thisWindow)
     {
     findScreenRes();

     var xWindowPos = (screenWidth / 2) - (myWidth / 2);
     var yWindowPos = (screenHeight / 2) - (myHeight / 2);
     thisWindow.moveTo(xWindowPos, yWindowPos);
     }
  //-->
  </script>

*END SNIPPET*

----- Original Message -----
From: Alex Shiell, ITS, EC, SE
Sent: October 8, 2001 10.57
To: javascript
Subject: [javascript] RE: Collecting window dimensions

I thought you wanted the popup to appear right in the middle of the screen?

-----Original Message-----
From: Kev Fields [mailto:drunkendruid@h...]
Sent: 08 October 2001 15:25
To: javascript
Subject: [javascript] RE: Collecting window dimensions


The screen.(width/height) get the screen res.
What I was looking for was the width and height of a window.
Thanks though.

----- Original Message -----
From: Alex Shiell, ITS, EC, SE
Sent: October 8, 2001 05.22
To: javascript
Subject: [javascript] RE: Collecting window dimensions

screen.width and screen.height for IE, not sure about NS and others

-----Original Message-----
From: Kev Fields [mailto:drunkendruid@h...]
Sent: 06 October 2001 16:11
To: javascript
Subject: [javascript] Collecting window dimensions



Hi,
I'm trying to write a script that centers a pop-up window in the middle of 
the viewer's screen, but I can't seem to figure out how to get the window 
dimensions for the pop-up.
I thought it would be something like window.width, window.height... but, 
no dice.
Anyone have any ideas?

  Return to Index