2

This Jquery open in a pop up how can i open this in new tab

<script src="http://code.jquery.com/jquery-latest.min.js"
        type="text/javascript"></script>
    <script type="text/javascript" >
        $(document).ready(function () {
                window.open( "http://www.google.com", "_blank");
        });
</script>
Golda
  • 3,823
  • 10
  • 34
  • 67

2 Answers2

1

I think that you can't control this. If the user had setup their browser to open links in a new window, you can't force this to open links in a new tab.

JavaScript open in a new window, not tab

if the user has set up their browser to open in a new tab then you have to invoke it from a click event and not on document load otherwise it will always be a popup.

use the following code for click events.

$(document).ready(function () {
    $('a').click(function (e) { // change 'a' to whatever selector your button is.
        window.open(
            "http://www.google.com",
            "_blank");
    });
});
Community
  • 1
  • 1
Yussuf S
  • 2,022
  • 1
  • 14
  • 12
-1

u have to try this

      $(function () {
$('a').click(function(){
       window.open('http://google.com','mywindow','width=400,height=200,toolbar=yes, 
    location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, 
    resizable=yes')
});
        });
Rahul jain
  • 110
  • 3
  • 12
  • This open in a new window. but i suppose to open in a tab. More over is there is any option to avoid pop-up block – Golda Sep 20 '13 at 11:44