Open the url in new window

Discussion in 'JavaScript' started by web@master24, Aug 3, 2010.

  1. #1
    Hello, im really dont know so much about js, i have a script what after a search send to a file:

        {
            if ( keyword!='Enter keyword to search Lyric!' )
                window.location.href = dle_root + 'file.php?searchtype=lyrics&key=' + keyword;
        }
    Code (markup):
    My question y how can i make for open the page in new window, no in the same, i hope somebody can help me. thank you
     
    web@master24, Aug 3, 2010 IP
  2. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #2
    You use window.open. Like this:
    
    <html>
    <head>
    <script type="text/javascript">
    function openlol( ) {
       mywindow = window.open ("http://rainulf.net/","mywindow","width=500,height=500"); // width/height here.
       mywindow.focus( ); // we use this to put the focus to the new window.
    }
    </script>
    </head>
    <body>
    
    <a href="#" onclick="openlol( );">Click me</a>
    </body>
    </html>
    
    HTML:
     
    Rainulf, Aug 3, 2010 IP