How can I get information if your PopUp window has been blocked? (HTML JS PHP)
FROM
window.open (URL, windowName[, windowFeatures]);
you open a new popup and as URL
you put some html page. On this popup page you write JS
in which you can use a variable window.opener
so that you can access everyone JS
from your main page. Then you can set some flag on the popup page - for example:
index.html
<html>
<body>
<script type="text/javascript">
var opened = false;
window.open('popup.html');
// and here some loop in mooTools/jQuery/or
// something to look up for variable changes
</script>
</body>
</html>
popup.html
<html>
<body>
<script type="text/javascript">
window.opener.opened = true;
</script>
</body>
</html>
I will do this.
Edit
And here's another way PHP
:
In popup.php
you can set some flag in session
$_SESSION['opened'] = true;
And in index.php
you should write something in AJAX
with an ana action request that will return you the value from $_SESSION
.
a source to share
The short answer is that you can't if you don't want to punish your users.
Popups are typically created client-side using JavaScript, so you cannot know if the popup was blocked from the server unless you look at comparing page content requests and popup content requests from the same IP addresses. This method gives an incredible amount of false positives and false negatives, although since if the user refreshes the page they may not get the popup a second time, they may have gotten it the first time. Or a popup can be generated and the content in that window can then be loaded independently of the content in the rest of the page. As a result, the only rational solution is completely unreliable.
So what you can do is write a JavaScript test to measure if the popup is generated the way it should be from JavaScript firing. When JavaScript runs, but the popup doesn't immediately exist, you'll have to disable AJAX to send you an alert so you are dynamically notified that the popup didn't load. However, if I had ever seen code like this, I would have crossed out my entire domain from my enterprise and warned the major security firms that you are either a malicious website or at risk.