0

I have a basic jquery issue. Just trying to make this link open in a new tab/window. I have added _blank but it does not go to a new page. Any ideas?

   $('#link13').click(function() {

    window.location.href= 'https://www.google.com','_blank';

  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button type="button" class="btn btn-primary" id="link13">See the Resources</button>
Vzupo
  • 1,388
  • 1
  • 15
  • 34

3 Answers3

1

Use window.open():

var win = window.open('https://www.google.com','_blank');
if (win) {
    //Browser has allowed it to be opened
    win.focus();
} else {
    //Browser has blocked it
    alert('Please allow popups for this website');
}

Depending on the browsers implementation this will work see this if it helps..

Saurabh Solanki
  • 2,146
  • 18
  • 31
0

In HTML you can use following:

<button class="btn btn-success" onclick=" window.open('http://google.com','_blank')"> Google</button>

Pure HTML Method:

<a href="https://google.com" target="_blank">Google</a>

l0n3sh4rk
  • 103
  • 3
0
$('#link13').click(function() {
    window.open(
      'https://www.google.com',
      '_blank' // <- This is what makes it open in a new window.
    );
});
Ahmad Gulzar
  • 355
  • 2
  • 8
  • 23