6

According to MDN Web Docs the allow attribute:

Specifies a policy feature for the <iframe>.

Source

The allow attribute uses Feature Policy. Feature Policy is made to developer allow some features of a certain site, but i don't understood for what this is for and how it works.

<iframe width="560" height="560" src="https://example.com" allow="camera; microphone"></iframe>

Please can give me examples?

3 Answers 3

1

Yes, exactly the attribute allow "specifies a feature policy for the <iframe>", but I don't really found very information about it and the values. But,for example, I use this code:

allow="geolocation"

in

<iframe id="form-iframe" src="https://google.com" allow="geolocation" width="800" height="600"></iframe>

Because I need that the web page can use the geolocation.

0

<iframe width="560" height="315" src="https://www.youtube.com/embed/owsfdh4gxyc" frameborder="0" allowfullscreen></iframe>

Enables a set of extra restrictions on any content hosted by the iframe. The value of the sandbox attribute can be either the empty string (all the restrictions are applied), or a space-separated list of tokens that remove each respective restriction.

Possible Values and Their Descriptions

allow-top-navigation Allows the nested browsing context to navigate (load) content to the top-level browsing context.

allow-same-origin Allows the content to be treated as being from its normal origin. Without this token, the content is forced into a unique origin, thus preventing it from accessing other content from the same origin. Also, without the allow-same-origin token, scripts are prevented from reading from or writing to the document.cookie IDL attribute, and blocks access to localStorage and openDatabase().

allow-forms

Allows form submission (i.e. the nested browsing context can submit forms). allow-scripts -Allows script execution (but not popup windows).

allow-pointer-lock

Enables Pointer lock. Pointer lock provides input methods based on the movement of the mouse over time, not just the absolute position of the mouse cursor. Pointer lock is useful for applications that require significant mouse input to control movements, rotate objects, and change entries. It is particularly essential for highly visual applications, such as those that use first-person perspective, as well as 3D views and modeling. By default, sandboxed iframes block Pointer lock. This attribute allows you to enable Pointer lock on sandboxed iframes.

allow-popups

Allows popup windows.

1
  • 1
    These properties apply to 'sandbox', the question was about the 'allow' attribute.
    – phayes
    Mar 4, 2022 at 18:46
0

A list of Permissions-Policy directives can be found at MDN.

E.g. for the accelerometer: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy/accelerometer

Use the menu on the left to navigate to other directives.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.