Click to See Complete Forum and Search --> : centering a popup
eliboone
11-21-2003, 09:13 AM
I would like to center my popup on the screen. Here is my javascript code.
<SCRIPT LANGUAGE="JavaScript">
function openindex()
{
OpenWindow=window.open("shippingpopup.html","newwin","height=125,width=275,toolbar=no,scrollbars='+scroll+',menubar=no");
}
</script>
What do I need to add to center this popup?
Thank You,
Eli
http://www.webdevfaqs.com/javascript.php#centeredpopup
eliboone
11-21-2003, 09:38 AM
Thanks for the reply Pyro. I added the following code to see if it would actually work with the way I had my script written.
<SCRIPT LANGUAGE="JavaScript">
function openindex()
{
OpenWindow=window.open("shippingpopup.html","newwin","height=125,width=275,toolbar=no,scrollbars='+scroll+',menubar=no");
}
var left = (screen.width - width)/2;
var top = (screen.height - height)/2;
var windowproperties = "width="+ width +",height="+ height +",left="+ left +",top="+top +",scrollbars=1";
</script>
My popup did move on the page, but is not quite centered. What should I change to my code?
Thank You,
Eli
By the looks of your code, it shouldn't have made any differenece adding that code in. I'd recommend doing it as seen at the link I provided above.
eliboone
11-21-2003, 10:29 AM
I didn't think it would move the popup either, but it did.
Your script is confusing to me. Does your popup "popup" only when someone clicks on the link or when they enter that page? I want my popup to "popup" whenver someone enters my index.html page.
csduk
12-01-2003, 10:15 AM
You could use this pop up generator:
http://javascript.internet.com/generators/popup-window.html
Regards.
With the code in the link I provided, just add this to your <body>'s onload tag:
<body onload="openwin('somepage.htm','600','400');">