Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2003
    Thanked 0 Times in 0 Posts

    math variable not working

    here's the function I call to pop up a window
    and center in depending on the monitor resolution.

    function doIt() {
    var centerW=((screen.width - 800) / 2);
    var centerH=((screen.height - 600) / 2);
    window.open('main.htm','EgrArt', 'height=600,width=800,location=no,left=centerW,top=centerH,scrollbars=no,resizable=no,menubar=no');

    centerW and centerH give the right numbers when I alert them, but they don't work within the window.open and I don't know why.

    Any help would be greatly appreciated

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Thanked 0 Times in 0 Posts
    You have to break from the string and concatenate so that their values are used

    window.open('main.htm','EgrArt', 'height=600,width=800,left=' + centerW + ',top=' + centerH );

    Also, so you know, any window property defaults to false, so you don't need to set all of them to 0. Just leave them out and they won't show up.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


    Posting Permissions

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