Disable all links inside IFRAME using jQuery

I was looking to disable iframe links too and couldn't find a solution. Thanks to HTML5, you can easily disable links by simply adding the sandbox attribute.

<iframe src="externalsite.com" sandbox></iframe>

view demo

I hope this helps someone searching the net, especially since this questions pops up first on Google.


I would expect that $(document).ready executes before the content of the iframe has loaded. Try using the onload attribute for the iframe instead.

Tags:

Jquery