View Full Version : Please help me with centering

10-04-2007, 09:08 PM
Hello :o

I want to use this exact popup script because I love it and i know how to use it.
(I don't want to changeto another popup script if I don't have to.)

Please can anyone tell me how to have this exact script make the popup
auto-center on everyone's screen no matter their resolution? Here is my script:

Step 1) Copy this code into the HEAD of your HTML document

<!-- Begin
function popUp1(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "',

'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=0,width=300,height=400,left = 362,top = 184');");
// End -->

Step 2) Use the following link to open the new window

<A HREF="javascript:popUp1('http://google.com')">Open</A>

10-05-2007, 05:28 AM
Browsers vary. There is no reliable way to take into account the height of the title bar, tool bar, scroll bar, location bar, and status bar chrome. You can approximate it at - say about 100. Also, you cannot use the exact script, obviously. It doesn't do what you want. So we may as well clean it up a bit.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">

function popUp1(URL) {
var day = new Date(), id = day.getTime(),
l = screen.width ? (screen.width-300)/2 : 0,
t = screen.height ? (screen.height-500)/2 : 0;
t=t<0? 0 : t;

<a href="http://google.com/" onclick="popUp1(this.href);return false;">Open</a>

10-05-2007, 02:19 PM
Hi John, thanks so much, as always!

Sorry, I meant "exact script" meaning not change to a completely different script I'm not familiar with. LoL. What you gave me looks great! I'll go try it out.

Thanks again. ;)