How to disable iframe from javascript?

Member

by darion , in category: HTML & CSS , 6 months ago

How to disable iframe from javascript?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by mallory_cormier , 6 months ago

@darion 

To disable an iframe using JavaScript, you can set the src attribute of the iframe to an empty string. Here is an example code snippet:

1
2
var iframe = document.getElementById('myFrame');
iframe.src = '';


This will effectively disable the iframe and it will not load any content. You can also hide the iframe by setting its display property to none:

1
iframe.style.display = 'none';


Additionally, you can remove the iframe from the DOM entirely by using the removeChild method:

1
iframe.parentNode.removeChild(iframe);


These methods will disable the iframe and prevent it from being displayed or loading any content.

Related Threads:

How to update an iframe with javascript?
How to disable all clicks in iframe?
How to disable toolbar in iframe?
How to disable right click on iframe?
How to disable scrolling for an iframe in chrome?
How to disable autoplay video in iframe?