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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    310
    Thanks
    86
    Thanked 3 Times in 3 Posts

    Launch a window on pop-up?

    Hello,

    On my site I want to launch a window when the page loads, which i've done like so:

    Code:
    <body onload="window.open('survey/front.php', 'newWindow', 'scrollbars=0,resizable=0,height=490,width=640')">
    But is this the best way to do it? Is there a better way either in CSS and will this conform to the W3C?

    Thank you

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,666
    Thanks
    6
    Thanked 1,006 Times in 979 Posts
    This is almost the correct way of doing it. The only thing to do regarding best practice is to move all JavaScript out of the HTML into an external file (this is called unobtrusive JavaScript) and only put a script reference in the head of the HTML document. Then the code would look something like this:
    Code:
    window.onload = funtion() {
      window.open('survey/front.php', 'newWindow', 'scrollbars=0,resizable=0,height=490,width=640');
    }
    However, note that many browsers have a popup blocker or people may have disabled the ability of scripts to open new or mess with current browser windows. The best most current way is to have kind of an internal popup, i. e. not a new window but a new “layer” appear inside the window on top of the page. There are many prefabricated scripts such as thickbox or multibox that can be set to pop up automatically after some time, or you can learn how to create such a popup yourself at http://dhtmlpopups.webarticles.org/


  •  

    Posting Permissions

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