screenX and screenY not working properly

M

Matt Stanley

I'm trying to use a popup window script that opens the new window to a
specific X,Y coordinate... I'm pretty sure that the window.screenX and
window.screenY properties are the answer, but I'm having very little success
in making this all work in both IE and NS.

Here's my code as it stands today:

function windowOpen3(URL, windowW, windowH) {
strWindow =
'toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,re
sizable=0,size=yes,width=' + windowW + ',height=' + windowH +
'screenX=100,screenY=100'
window.open(URL,'hwWindow',strWindow)
}

IE is ignoring the X,Y coordinates completely and opening the new window so
far over to the right that half of it is off-screen and NS is picking up the
screenY setting but ignoring screenX.

Am I missing something here? Please help, and TIA.

Stanman
 
L

Lasse Reichstein Nielsen

Matt Stanley said:
'toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,re
sizable=0,size=yes,width=' + windowW + ',height=' + windowH +
'screenX=100,screenY=100' ....
IE is ignoring the X,Y coordinates completely

Yep. They never claimed to understand it.
NS is picking up the screenY setting but ignoring screenX.

Missing "," before "screenX".
Am I missing something here? Please help, and TIA.

I recommend using "left" and "top" instead of "screenX" and "screenY".
These properties seem to work in all browsers since Netscape 4 (do tell
me if you find exceptions :)
<URL:http://www.infimum.dk/HTML/JSwindows.html#ref_3_2>

While it is not documented by Netscape, "left" and "top" it seems to
be supported from (at least) Netscape 4.08.
(<URL:http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1202731>)
I doesn't work in Netscape 3, but that's not really a problem any more.

Actually, I recommend aginst trying to position windows at all. In MDI
browsers or dual-monitor displays, it can be quite disruptive, and in other
browsers, it's usually not needed.
<URL:http://www.infimum.dk/HTML/JSwindows.html#ref_3_3>

/L
 
L

Lee

Matt Stanley said:
I'm trying to use a popup window script that opens the new window to a
specific X,Y coordinate... I'm pretty sure that the window.screenX and
window.screenY properties are the answer, but I'm having very little success
in making this all work in both IE and NS.

Here's my code as it stands today:

function windowOpen3(URL, windowW, windowH) {
strWindow =
'toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,re
sizable=0,size=yes,width=' + windowW + ',height=' + windowH +
'screenX=100,screenY=100'
window.open(URL,'hwWindow',strWindow)
}

IE is ignoring the X,Y coordinates completely and opening the new window so
far over to the right that half of it is off-screen and NS is picking up the
screenY setting but ignoring screenX.

Am I missing something here? Please help, and TIA.

You're missing a comma before "screenX".
You've invented an attribute named "size".
IE ignores screenX and screenY, expecting left and top, instead.
You don't need to list attributes that are set to "no", since that
is the default if you specify values for any other attributes:

function windowOpen3(URL, windowW, windowH) {
strWindow = 'width=' + windowW + ',height=' + windowH
+ ',screenX=100,screenY=100,top=100,left=100';
window.open(URL,'hwWindow',strWindow);
}
 
M

Matt Stanley

Thanks so much for your help! That TOTALLY worked. It's always nice when
developers help each other; you guys both just made my day!
 
M

Matt Stanley

Thanks so much for your help! That TOTALLY worked. It's always nice when
developers help each other; you guys both just made my day!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top