It's a setting in chrome. You can't control how the browser interprets the target _blank.
It's a setting in chrome. You can't control how the browser interprets the target _blank.
"_blank" is not guaranteed to be a new tab or window. It's implemented differently per-browser.
You can, however, put anything into target. I usually just say "_tab", and every browser I know of just opens it in a new tab.
Be aware that it means it's a named target, so if you try to open 2 URLs, they will use the same tab.
window.open(url, '_blank'); not working on livepreview
window.open(url, '_blank'); not working on iMac/Safari
Could not access window created using window.open('about:blank' .... code
Trying to open URL in new tab - target _blank not working | OutSystems
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;
});
Using setTimeout
EDIT: A few people are reporting that this method doesn't work anymore on the latest Safari.
Wrapping your window.open(url, '_blank') line of code in the async function with a setTimeout works as well,
setTimeout(() => {
window.open(url, '_blank');
})
EDIT 25/04/2025: Some people reported that using _top works, instead of using _blank
setTimeout(() => {
window.open(url, '_blank');
})
setTimeout code runs on the main thread, instead of the asynchronous one. Tested in Chrome and Safari.
While it's no longer possible to do this in Chrome, there are workarounds, such as opening a blank document and writing to it.
var win = window.open();
win.document.write("<img src='"+canvas.toDataURL()+"'/>");
That's because of a recent change in Chrome:
https://developers.google.com/web/updates/2017/03/chrome-58-deprecations#remove_content-initiated_top_frame_navigations_to_data_urls
You cannot open data URLs directly anymore this way for security reasons.
Instead use the workaround proposed by @Savoo here in the other answer or use a download anchor and click it via JavaScript.
try this
onclick="window.open('http://www.google.com', '_self');
well it is browser specific, i tested it on mozilla and is working fine, but on chrome it open in new browser window. You can suggest to chrome makers or call ajax synchronus.
use async:false will work.
NOTE: In IE, open new browser window is default behaviour. user need to set settings explicitly