Results 1 to 2 of 2

Thread: Centre Pop of window

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    32

    Centre Pop of window

    Is there a way to centre a pop up window called from Javascript instead of having it pop up where it fancies?

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Here's an example:

    Code:
    <script type="text/javascript">
        var h = 500;
        var w = 500;
        
        var l = (screen.width - w) / 2;
        var t = (screen.height - h) / 2;
        
        window.open('about:blank', 'blank', 'width='+w+', height='+h+', top='+t+', left='+l); 
    </script>
    h is the height you want the window to be, w is the width.

    It then calculates what the top and left needs to be for it to be centered and opens the window.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

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



Click Here to Expand Forum to Full Width