I'm embedding video that has an exit pop-up banner ads and video ads. When you anywhere in video then popups open automatic or how to click on X icon to close banner ad.
.iframe{
width: 100%;
float: left;
margin-top: 5px;
}
<div class="iframe">
<iframe width="1000" height="600" src="https://www.youtube.com/embed/Sb_60g3u1LU" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>
</div>
I am using other third party websites to host videos like vidzi.tv & openload.co and these sites are full with pop ups and banner ads in video player.
If you want to block an iframe from opening windows, you can use the new HTML5 "sandbox" attribute on your iframe.
AdBlock blocks pop-ups by default. Once you've installed it, you should stop seeing annoying pop-ups in Chrome, Firefox, Edge, Safari, Android or iPhone. If you're still seeing pop-ups, it could be a sign that your computer has been infected with a form of malware called "adware".
You can add sandbox
attribute in your iframe. Only the values you add to the attribute will be allowed. Any value you do not add in the sandbox
attribute will not be allowed by browser.
Sandbox attribute has following values:
allow-forms
allow-pointer-lock
allow-popups
allow-same-origin
allow-scripts
allow-top-navigation
I have modified your code to include sandbox option, but have NOT added allow-popups
, so popups will not be allowed in this iframe.
<div class="iframe">
<iframe sandbox = "allow-forms allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation" width="1000" height="600" src="https://www.youtube.com/embed/Sb_60g3u1LU" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>
</div>
You can find more about sandbox attribute here. Please note that this attribute is new in HTML5.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With