Trying to open a popup when popups are blocked, FF warns and add a button allowing to add an exception. Then it opens the blocked content. How to avoid this?
My system needs popups not being blocked to work properly. So I test this right after login (bellow follows a simple code):
<script type="text/javascript"> //<![CDATA[ function checkPopupsBlocked() { popupWindow = window.open("testingBlockedPopups.html", "testWindow", "width=300, height=100, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no"); try { popupWindow.focus(); } catch (e) { alert("Popups are blocked"); } // it will be null when popups are blocked if (!popupWindow === null && !popupWindow === undefined) { popupWindow.close(); } } //]]> </script>
When popups are blocked, it shows the alert. When I close the alert, FF shows right bellow the address bar a button offering the possibility to add an exception for the current site. If I add the exception, my "testWindow" is automatically opened, which is undesirable (Chrome, for example, doesn't do this). Is there a programatically way to prevent testWindow to be opened in this situation?
ప్రత్యుత్తరాలన్నీ (1)
Code was removed when posting the original question, so I'm trying again:
function checkPopupsBlocked() { popupWindow = window.open("testingBlockedPopups.html", "testWindow", "width=300, height=100, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no");
try { popupWindow.focus(); } catch (e) { alert("Popups are blocked"); }
// it will be null when popups are blocked if (!popupWindow === null && !popupWindow === undefined) { popupWindow.close(); } }
and then I call it on body onload.