How to disable an iframe in javascript? [closed]

How can an iframe be disabled using Javascript, such that the user is unable to interact with the iframe's contents (i.e. scrolling, selecting, dragging, etc)? For example, a Google map in an iframe can normally be dragged and zoomed. How would these actions be prevented?



If you're wanting to disable mouse interaction, this should work.

Put a DIV over the top of your iframe, like so (replace top, left, width and height values with your own):

<div id="blank" style="display:none; position:absolute; top:100px; left:100px; width:600px; height:400px;">

and when you want to disable the iframe, do this in javascript:


I don't know if you can use the disabled property like input elements, but you could disable mouse interaction by placing an element over the iframe, though this doesn't stop a user from tabbing to it.

Probably the best bet is to set the src attribute to blank, but this will make the iframe blank, not blurred.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.