0

I am trying to open multiple websites, attaching the sample code.

Code works but it opens only one website and then gives a blocker popup. Once I click on "Always allow pop-ups and redirects" it works. Is there a way this can be avoided.

I checked below article and but didn't get the solution

Avoid browser popup blockers

enter image description here

<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="utf-8" />
    
    <script type="text/javascript">

        function openWebsites() {
            window.open("https://www.google.com/")
            window.open("https://www.facebook.com/")
            window.open("https://stackoverflow.com/")
        }

    </script>
</head>
<body>
    <div class="center">
        <input type="button" value="Open Websites" onclick="openWebsites()"
               title="Open"  />
    </div>
    <footer>
        
    </footer>
</body>
</html>
Jain Prince
  • 383
  • 1
  • 6
  • 19
  • This is exactly why popup blockers exist. You may not have anything malicious in mind, but other people do. If you try to call `window.open` more than once per user interaction, it will be blocked. The real question is why you would want to do this? And if there is a good reason, then just tell your users to allow popups on your website. If there was any easy way to circumvent popup blockers, that would be **a very bad thing**. – Liftoff Sep 02 '21 at 05:42

0 Answers0