0

I am trying to open a URL in Jquery which works fine however I would like the window to open in a target _new way.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(location).attr('href', 'http://www.google.com');
</script>

I have tried adding

.attr('target','new');

and some variations but to no joy. Thanks in advance.

Clive Atkins
  • 545
  • 4
  • 21

1 Answers1

2

If you want open url in new page you can use:

window.open("http://stackoverflow.com/", '_blank');

Demo: https://jsfiddle.net/cmedina/mxfqo12o/

CMedina
  • 4,034
  • 3
  • 24
  • 39