Поиск в Поддержке

Избегайте мошенников, выдающих себя за службу поддержки. Мы никогда не попросим вас позвонить, отправить текстовое сообщение или поделиться личной информацией. Сообщайте о подозрительной активности, используя функцию «Пожаловаться».

Learn More

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?

  • 1 ответ
  • 1 имеет эту проблему
  • 7 просмотров
  • Последний ответ от Cássio

more options

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?

My system needs popups not being blocked to work properly. So I test this right after login (bellow follows a simple code): <html> <head> <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> </head> <body onload="checkPopupsBlocked();"> </body> </html> 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)

more options

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.