Click to See Complete Forum and Search --> : Popup Window coordinates


Arc
06-02-2003, 07:37 PM
Hi.. Is there any possible way to set the screen coordinates of a popup window?

Thanks!:D

Lizo
06-02-2003, 07:53 PM
window.open("http://www.google.com","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no ,width=400,height=400,top=50,left=50")


its the top= and left= are the attributes u need

gil davis
06-02-2003, 07:54 PM
Assuming by pop-up window you mean you are using window.open(...);you can usewindow.open("...", "...", "top=100,left=100");to position the window 100px from the top and 100px from the left edge of the user's screen.

See http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp for a full explanation.

Charles
06-03-2003, 05:12 AM
1) "top" and "left" are MSIE specific. If you want this to work in Netscape you will need to use "screenX" and "screenY".

2) In one of the Opera modes, the new window will open relative to parent, not relative to the screen.

gil davis
06-03-2003, 07:17 AM
The reference for opening a window in Netscape Javascript 1.3:

http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1202731

You can also move the window after it is open usingmoveTo(x, y);See http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1202631 for Netscape, and http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/moveto.asp for IE.

Perhaps someone else can elaborate on Opera, etc.

Charles
06-03-2003, 08:29 AM
But not as of JavaScript 1.3 (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1202731).

Arc
06-03-2003, 01:51 PM
Ok cool thanks! I assumed that's waht it was but wasn't sure.

OK how would i center it on the screen?

In VB it would be like

top=screen.twipsperpixelY /2
left=screen.twipsperpixelX /2

but not sure what the functions are in JS

thnaks!:D

Jona
06-03-2003, 02:41 PM
Center of the screen?


window.moveTo(screen.width/2, screen.height/2);


(I ThinK ;))
Jona

diamonds
06-03-2003, 02:53 PM
Originally posted by Jona
Center of the screen?


window.moveTo(screen.width/2, screen.height/2);


(I ThinK ;))
Jona


sheesh...

you are right!

here's another way:
<html>
<head>
<script>
function onload(){
var wide = screen.width/2;
var high = screen.height/2;
window.moveTo(wide,high);
}
</script>
</head>
<body onload="onload()">
</body>
</html>

Jona
06-03-2003, 02:56 PM
The "me" show off? And who would that be?

Just Wondering,
Jona

diamonds
06-03-2003, 03:07 PM
Let me guess.....
hummmmmm......
weeeellllllll,
errrrr.....

:D meeeeeeeeeeeeeeeeeeeeeeee :D

Jona
06-03-2003, 03:11 PM
LOL

:DJona

Arc
06-03-2003, 03:15 PM
hmm... I am using this function


function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
window.moveTo(screen.width/2, screen.height/2);
}


The problem is it moves the window that has the link instead of the popup window it is creating....

I tried this...

<a href="#" onClick="MM_openBrWindow('includes/2003mail.php?ID=<?php Print $ResultArray[VehicleID]; ?>','','width=435,height=420,top=screen.height/2,left=screen.width/2')">Interested in this Vehicle?</a><br>


But that just set the coordinates to 0,0

Jona
06-03-2003, 03:17 PM
function MM_openBrWindow(theURL,winName,features){ //v2.01
var MM_win = window.open(theURL,winName,features);
MM_win.moveTo(screen.width/2, screen.height/2);
}


Jona

Arc
06-03-2003, 03:29 PM
Ok cool it's moving the right window now! Thanks.

The problem is it centers the top left corner of the window on the screen instead of the center of the window on the center of the screen.

The code needs to take into account window hieght and width and divide them in half.

example:

window.moveTo(screen.width/2-window.width/2, screen.height/2-window.height/2);


but that doesn't work...

Jona
06-03-2003, 03:58 PM
window.moveTo(window.width/2, window.height/2);


I think,
Jona

Jona
06-03-2003, 06:28 PM
Originally posted by Jona
I think,

The quote says it all.. Didn't test it. :p

(What are you trying to do disgrace me!? :D Just kidding. lol)
Jona

Jona
06-03-2003, 06:39 PM
'Twas a joke, my friend. In happy mood am I today, although busy. :p

Jona

Charles
06-03-2003, 06:41 PM
Originally posted by Dave Clark
Tell that to NS4 -- where the link I provided also works perfectly (I made sure to test it, too, before I posted my first comments on the subject). And I just tested it on Netscape 4.77 which only supports JavaScript 1.3. And no, the MSIE specific "top" and "left" did not work.

Khalid Ali
06-03-2003, 06:50 PM
No doubt top and left were I specific.Not anymore though.
For the record Charles....you have mentioned on these forums a tonnes of times that <=NS4.7 is only used by a meagre 3% of the Internet browsing people...And you recomend people yourself to do not worry about that browser any more...on the same issue you say that it matters if top and left were or are IE specifci.?

To me it sounds contradictory....:-)

For the record....there are allots of things that have been adapted in NS6+ browsers from IE....top,left innerHTML are to name a few...

On a very personal note:
I think if I write my code today that works perfectly in NS6+ using standard DOM1 and CSS1, I think I seriously don't have to worry about IE or any other browsers..cus 99% of the time my code will work with all generation6+ browsers.
:D

Charles
06-03-2003, 07:36 PM
Khalid, fair enough. Tis true, it's no great loss if the child window isn't positioned according to the web author's desire. The bigger problem is that Opera gets it wrong sometimes. pera has two different interface modes. WIth the mode that works like MSIE, where new windows open up in OS, there is no problem. But with the mode that works like Excel, where new windows open up within the application, positioning is understood as relative to the application. I would suggest that one use something more like if (navigator.appName != 'Opera') child.moveTo(x,y).

Arc
06-03-2003, 09:46 PM
cool that works dave. It's acting kinda wierd though. It like showing in the left corner and then disapearing then reapearing in the center of the screen briefly looking as though it is loading the page that called it then it loads the page it's supposed to.

In other words it works but it's real flickery and not so elligant looking.

Using the top,left properties in the directly in the onclick event works much more smoothly as it's not drawing the window then closing it then redrawing it again.

is there anyway to do it like this?

<a href="#" onClick="MM_openBrWindow('includes/2003mail.php?ID=<?php Print $ResultArray[VehicleID]; ?>','','width=435,height=420,top=(screen.height-420)/2,left=(screen.width-435)/2')">

Arc
06-04-2003, 11:40 AM
thats perfect dave! Thanks alot!

Arc
06-04-2003, 07:47 PM
thats what the Href="#" is for.