Forum Moderators: open

Message Too Old, No Replies

>> How To Position Popup On Page <<

Need information...

         

Texas

6:29 am on Jul 24, 2002 (gmt 0)

10+ Year Member



Hello WebMasterWorld,

I'm up to my ears in xy coordinates and still I'm unable to resolve my problem...how to position the location of a popup on a page.

I prefer to limit javascript to bare-bones, and keep any and all of it down towards the bottom of an html document.

For a site I'm building, I use three popups per page (for contact, link-to-us and a disclaimer). The below is how one of them is configured.

Link to contact is:

<a href="javascript:openpopup()">Contact</a>

Script action:

<script type="text/javascript" CHARSET="ISO-8859-1">

function openpopup(){
var popurl="contact.html"
winpops=window.open(popurl,"","width=420,height=400,scrollbars,resizable,")
}

</script>

Now, using the simple protocol above, any advice for how can I tweak the script to position the popup to an absolute top-left location would be most appreciated.

...if possible without adding anything else to head tags or body.

Thanks,

Texas

Purple Martin

7:03 am on Jul 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is a copy & paste from something I did last week (it was a colour picker):

theChild = window.open("colour.htm?c="+bgc, "colourWindow", "height=121,width=145,screenX=200,screenY=200,left=200,top=200");


That will position the popup 200px down and left on the screen. Now if only you knew the position of the browser on the screen... well in N6 you can use screenX and screenY to get the top left coords of the browser window, screenLeft and screenTop do the same in IE5 (except on Macs), but you still don't know how much browser chrome is there (address bar, toolbars etc), so I can't think of a way to position the popup exactly over your page.

Can anyone else do better than me?

Texas

7:22 am on Jul 24, 2002 (gmt 0)

10+ Year Member



Excellent Purple M,

Seems to work just fine...just what I wanted.

Here's what I used from your example:

<script type="text/javascript" CHARSET="ISO-8859-1">

function openpopup(){
var popurl="contact.html"
winpops=window.open(popurl,"","width=420,height=400,scrollbars,resizable,screenX=2,screenY=2,left=2,top=2,")
}

</script>

Many thanks!

Texas