allowfullscreen
an HTML attribute for the iframe tag

Can I disable allowfullscreen for an iframe?

Answers:

  • Yes, you can disable the allowfullscreen attribute for an <iframe>. To do so, simply do not include the allowfullscreen attribute in your <iframe> tag. If the attribute is not present, users will be prevented from going full-screen using that iframe.

    Here’s an example of a simple <iframe> without the allowfullscreen attribute:

    <iframe src="https://example.com" width="600" height="400"></iframe>
    

    If you have an existing iframe that includes the allowfullscreen attribute and you want to disable it, you can remove that attribute from the iframe code:

    <!-- Before (with allowfullscreen) -->
    <iframe src="https://example.com" width="600" height="400" allowfullscreen></iframe>
    
    <!-- After (without allowfullscreen) -->
    <iframe src="https://example.com" width="600" height="400"></iframe>
    

    It's important to note that some websites may still have their own configurations that could affect how their content displays in an iframe, but by not including allowfullscreen, you are instructing the browser not to permit full-screen mode for that iframe.

Related Questions: