SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Knowledge is key 2 progression Tryst's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Centralising a JS popup window

    Hi all,

    if I have the following JS code, how can I change it so that the popup browser window loads centrally on the monitor?

    Code:
    <script language ='Javascript'>var win=window.open('../BE_freedom_access/CompanySearch.aspx','null','width=1000,height=800,scrollbars=1','true');</script>
    Thanks

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    You can get information about finding the screen dimensions at http://www.quirksmode.org/viewport/compatibility.html

    Information about controlling the popup window is at http://www.quirksmode.org/js/croswin.html
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    create a javascript function such as pop_window() which detects the width and height of the screen. Subtract the width and height of the window from the width and height of the screen and divide by two. Your left with two values, this will be the x,y position that you use in your window.open call.

    here is a link with some example code ....

    http://www.java-scripts.net/javascri...p-Window.phtml
    intragenesis, llc professional web & graphic design

  4. #4
    SitePoint Addict Bravogolf's Avatar
    Join Date
    Aug 2004
    Location
    All over really :)
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this what you're looking for?


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
  •