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 Coder
    Join Date
    May 2003
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    centering a browser window

    Could someone do me the favour of looking at this script, played about with it, but no luck, cant get it to center and have the right size window...
    This is called from flash
    Thanks much appreciated

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var newWin;
    function openWindow1() {
    var w = 760;
    var h = 520;
    var x = (screen.width-w)/2;
    var y = (screen.height-h)/2;
    var settings = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',h eight='+h+',left='+x+',top='+y+'",
    newWin=window.open("home.htm","home",settings);
    newWin.focus()
    }
    -->
    </script>

  • #2
    New Coder
    Join Date
    Jul 2003
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There were some small mistakes in the settings variable. Try using this script (the typos were in the settings variable)

    Code:
    var newWin;
    function openWindow1() {
    var w = 760;
    var h = 520;
    var x = (screen.width-w)/2;
    var y = (screen.height-h)/2;
    var settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+x+",top="+y;
    newWin=window.open("home.htm","home",settings);
    newWin.focus()
    }

  • #3
    New Coder
    Join Date
    May 2003
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Wickford for your correction
    It works fine now.

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    maybe is better to use
    screen.availHeight and screen.availWidth

    because you don't know if user has small/large icons with text/notext labels on browsers toolbar, or if he uses hidden/visible bottom/up/left/right Windows Toolbar...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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