How to block pop-up coming from iframe?

by haylee.mertz , in category: Javascript , a year ago

How to block pop-up coming from iframe?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by edmond_brakus , a year ago

@haylee.mertz 

To block pop-ups coming from an iframe, you can use JavaScript to detect and prevent them. Here's an example of how to achieve this:

  1. Identify the iframe element in your HTML code using an ID or class.
  2. Add an event listener to the iframe to detect when it loads the content.
  3. Write the function blockPopups to prevent pop-ups from opening.


By overriding the window.open function inside the iframe, any pop-up attempts within the iframe will be blocked. You can modify the action taken when detecting a pop-up attempt based on your requirements.