Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2004
    Location
    Kent, England
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to center a window?

    I know how to position a window by pixel coordinates, but does anyone know how to open a window and have it centered no matter what the screen resolution is set at
    My imaginary friend just told me I have serious psychological problems!

  • #2
    New to the CF scene
    Join Date
    Nov 2004
    Location
    Kent, England
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Have just worked it out

    Quite simple really. If anyone is interested:

    <script>

    var w=(screen.width-400)/2;
    var h=(screen.height-300)/2;

    window.open("something.html", "", "width=400, height=300, left="+w+", top="+h+"")

    </script>
    My imaginary friend just told me I have serious psychological problems!

  • #3
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    I made a function a few years ago that did just that.

    you may be interested in it. its at newwindow.info (link in sig.)
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."

  • #4
    New Coder
    Join Date
    Oct 2004
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello World,

    Nice quote on your sig, there, eak.

    lol, I guess that wasn't related to the subject.

    Goodbye World,
    --Shen


  •  

    Posting Permissions

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