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

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

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