Open Browser in New Window Using Javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saurabhmca2003
    New Member
    • Nov 2008
    • 1

    Open Browser in New Window Using Javascript

    Code:
    <script language="javascript" type="text/javascript">
    function open_()
    {
        window.open('http://www.yahoo.com');
    }
    </script>
    
    <a href="javascript:open_()" >About Restaurant</a>
    does not work at all.
    If we click(left) on the 'About restaurant' link, the new window in open. But if we right click-> open a new window, it will just show "javascript:ope n_()" in address bar. This thing seems to appear in IE6. While working perfectly fine with IE7.

    Please give suggestion or solution for this as son as possible.
    thank you:
    Last edited by acoder; Nov 19 '08, 06:11 PM. Reason: Added [code] tags
  • serdar
    New Member
    • Nov 2008
    • 88

    #2
    I have IE7 installed so I couldn't test in IE6.

    Please try:
    [HTML]<a href="javascrip t:window.open(' http://www.yahoo.com') ;">About Restaurant</a>[/HTML]

    There are other methods to open a link in new window if this fails.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Avoid the "javascript :" protocol for the link href attribute - see usability issues. Use a real URL for the href, i.e. http://www.yahoo.com.

      Comment

      Working...