Akash Limbani
Akash Limbani

Reputation: 1351

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.

Upvotes: 0

Views: 642

Answers (1)

7cc
7cc

Reputation: 1169

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
}

Upvotes: 1

Related Questions