SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict webmistress's Avatar
    Join Date
    Aug 2002
    Location
    Derbyshire, UK
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Window centered

    Does anyone know how to open a window that's a particular size and centers it on the screen?

    I can't get it working.

    Thanks
    ****************
    The Webmistress

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a C & P of a function I got laying around for that
    Code:
    function placePopup( url, targ, w, h )
    {
     var features = "";
     var screenWidth = 800;
     var screenHeight = 600;
     var popWidth = 740;
     var popHeight = 410;
     if (window.screen)
     {
      screenWidth = window.screen.availWidth;
      screenHeight = window.screen.availHeight;
     }
     if (screenWidth > screenHeight * 2)
      screenWidth = screenWidth / 2;
     features += 'width=' + popWidth;
     features += ', height=' + popHeight;
     features += ', top=' + ( screenHeight/2 - w/2 );
     features += ', left=' + ( screenWidth/2 - h/2 );
     window.open( url, targ, features );
    }
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Member
    Join Date
    Nov 2003
    Location
    Canada
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't worry... Just go follow this link:

    http://www.webdevtips.com/webdevtips.../openwin.shtml

    There you have a cross-browser Advanced window opener, sized and centered.

    See also Pop-up Borderless centered Window here:

    http://www.phpfreaks.com/quickcode/P...Window/209.php


    Good luck.

    Cosmos2000
    Website: http://www.chez.com/cosmos2000/Numbers/666.html


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
  •