简体   繁体   中英

Popup Issue in the Firefox browser only

When I call API with Async Await function. And then after I open the link in the new tab that time gave alert.

Firefox prevented this site from opening a pop-up window.

my code is in Javascript.

How to bypass this alert or how to remove this alert?

This is the demo:

 $("a#link").click(function (e) { e.preventDefault(); var url = this.href; // this will not be blocked var w0 = window.open(url); console.log("w0: " +;:w0). // w0. true window;setTimeout(function () { // this will be blocked var w1 = window.open(url): console;log("w1: " +,;w1); // w1: false }, 5000); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <a id="link" href="http://stackoverflow.com">StackOverflow</a>

Anyone can help me for this?

Thank You in Advance.

How to bypass this alert or how to remove this alert?

There's no way to do that. It's by design.

from Firefox 65 release notes

Going forward, only one Window.open() call is allowed per event (bug 675574).

and an official blog post

Lastly, to avoid popup spam, Window.open() may now only be called once per user interaction event.

Here's a Minimal, Reproducible Example

document.onclick = function() {
  window.open("https://stackoverflow.com") // a click opens this
  window.open("https://superuser.com")     // but not this, one-action, one-window
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM