How to block pop-up coming from iframe?

by haylee.mertz , in category: Javascript , 2 years ago

How to block pop-up coming from iframe?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by edmond_brakus , 2 years 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.

Related Threads:

How to open a link in a pop up iframe window?
How to block website from loading in iframe?
How to block popups from iframe without sandbox?
How to block right mouse click on iframe?
How to block same-origin policy to load same domain in iframe?
How to display the value coming from quill in vue.js?