Does anyone know why the following code wouldn't work?

<html>
<body>
<iframe id="myVideo" width="560" height="315" src="https://www.youtube.com/embed/ZnuwB35GYMY" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
	
	<script>
	var b = document.getElementById("myVideo")
	b.setAttribute("disabled", "");
	</script>
</body>
</html>

HTMLIFrameElement does not have a disabled attribute.

Bear in mind that an iframe is a whole new browser context. That means you can write an entire HTML page within it. Perhaps consider using another means of embedding the video in the iframe?

1 Like