Results 1 to 3 of 3

Thread: Please help me with centering

  1. #1
    Join Date
    May 2007
    Posts
    97
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default Please help me with centering

    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


    <SCRIPT LANGUAGE="JavaScript">
    <!-- 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 -->
    </script>



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

    <A HREF="javascript:popUp1('http://google.com')">Open</A>
    Last edited by jscheuer1; 10-05-2007 at 04:32 AM. Reason: disable smilies

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,070
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    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.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <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;
    popUp1['i'+id]=window.open(URL,'i'+id,'toolbar,scrollbars,location,statusbar,width=300,height=400,left='+l+',top='+t);
    }
    
    </script>
    </head>
    <body>
    <a href="http://google.com/" onclick="popUp1(this.href);return false;">Open</a>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2007
    Posts
    97
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •