Thread: Browser window

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0

    Browser window


    Hello to all i need to open new browser window automatically.
    Here is code where i have to click on button to open window :
    <!DOCTYPE html>
    <html>
    <head>
    <script>
    function openWin()
    {
    myWindow=window.open('','','width=200,height=100');
    myWindow.document.write("<p>This is 'myWindow'</p>");
    myWindow.focus();
    }
    </script>
    </head>
    <body>

    <input type="button" value="Open window" onclick="openWin()" />

    </body>
    </html>

    Please how i can open window , without clicking on button so window just open automatically ?
    Thank You
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    50
    Rep Power
    35
    You could use window.onload:
    Code:
    <script type="text/javascript">
    window.onload = function openWin() {
        myWindow = window.open('', '', 'width=200,height=100');
        myWindow.document.write("<p>This is 'myWindow'</p>");
        myWindow.focus();
    };
    </script>
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0
    Thank you it works i enable pop-up and it is great

IMN logo majestic logo threadwatch logo seochat tools logo