Friday, May 10, 2024
125
rated 0 times [  126] [ 1]  / answers: 1 / hits: 17219  / 8 Years ago, sun, september 11, 2016, 12:00:00

I need to know when the user clicks on the button that triggers window.open if there is stable API/way to know beforehand if the user actively has a pop-up blocker?



In some cases the user doesn't know/pay attention that they have pop-up blocker (that block the new window). I would like to inform them by some dialog/or something to authorize a new window by clicking on allow.


More From » google-chrome

 Answers
3

Window.open(...) returns a handle to the new window if it exists. If it doesn't have a handle to the new window, that's a pretty good indication the window was blocked.



https://developer.mozilla.org/en-US/docs/Web/API/Window/open



From: https://davidwalsh.name/popup-block-javascript



var windowName = 'userConsole'; 
var popUp = window.open('/popup-page.php', windowName, 'width=1000, height=700, left=24, top=24, scrollbars, resizable');
if (popUp == null || typeof(popUp)=='undefined') {
alert('Please disable your pop-up blocker and click the Open link again.');
}
else {
popUp.focus();
}

[#60751] Thursday, September 8, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
austynp

Total Points: 505
Total Questions: 118
Total Answers: 106

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
austynp questions
;