window.open(url, '_blank'); not working on iMac/Safari window.open(url, '_blank'); not working on iMac/Safari javascript javascript

window.open(url, '_blank'); not working on iMac/Safari


Safari is blocking any call to window.open() which is made inside an async call.

The solution that I found to this problem is to call window.open before making an asnyc call and set the location when the promise resolves.

var windowReference = window.open();myService.getUrl().then(function(url) {     windowReference.location = url;});


To use window.open() in safari you must put it in an element's onclick event attribute.

For example:<button class='btn' onclick='window.open("https://www.google.com", "_blank");'>Open Google search</button>


Taken from the accepted answers comment by Steve on Dec 20, 2013:

Actually, there's a very easy way to do it: just click off "Block popup windows" in the iMac/Safari browser and it does what I want.

To clarify, when running Safari on Mac OS X El Capitan:

  1. Safari -> Preferences
  2. Security -> Uncheck 'Block pop-up windows'