I have code like this:
window.open('https://api.instagram.com/oauth/authorize/',
'_blank',
'width=700,height=500,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0,modal=yes');
This works fine when is called from any place of code, but when I use it in promise (see below), it is always blocked by browser. Any suggestions?
action().success(function (r) {
// window.open(...);
}
Promises are from angular.
Using Chrome's window. Native window. open() allows synchronous access to opened windows so it is convenient choice if you need to open a dialog or a preferences window.
A secure way to block popups is to specify a sandbox using the content security policy header. Content-Security-Policy: sandbox allow-scripts; In sandbox mode a lot of functionality is disabled, including popups: allow-popups: Allows popups (like from window.
open() The open() method of the Window interface loads a specified resource into a new or existing browsing context (that is, a tab, a window, or an iframe) under a specified name.
var newTab = $window.open('', '_blank');
promise
.then(function () {
var url = '...';
newTab.location.href = url;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With