HTML <iframe> sandbox kenmerk
Voorbeeld
'n <iframe> met ekstra beperkings:
<iframe src="demo_iframe_sandbox.htm" sandbox></iframe>
Meer "Probeer dit self" voorbeelde hieronder.
Definisie en gebruik
Die sandbox
kenmerk maak 'n ekstra stel beperkings vir die inhoud in die iframe moontlik.
Wanneer die sandbox
eienskap teenwoordig is, en dit sal:
- behandel die inhoud as van 'n unieke oorsprong
- blokvorm indiening
- blok script uitvoering
- deaktiveer API's
- verhoed dat skakels ander blaaikontekste teiken
- verhoed dat inhoud plugins gebruik (deur
<embed>
,<object>
,<applet>
, of ander) - verhoed dat die inhoud sy topvlak-blaaikonteks navigeer
- blokkeer outomaties geaktiveerde kenmerke (soos om 'n video outomaties te speel of om 'n vormbeheer outomaties te fokus)
Die waarde van die sandbox
kenmerk kan óf leeg wees (dan word alle beperkings toegepas), óf 'n spasie-geskeide lys van vooraf gedefinieerde waardes wat die spesifieke beperkings sal VERWYDER.
Blaaierondersteuning
Die nommers in die tabel spesifiseer die eerste blaaierweergawe wat die kenmerk ten volle ondersteun.
Attribute | |||||
---|---|---|---|---|---|
sandbox | 4.0 | 10.0 | 17.0 | 5.0 | 15.0 |
Sintaksis
<iframe sandbox="value">
Eienskapwaardes
Value | Description |
---|---|
(no value) | Applies all restrictions |
allow-forms | Allows form submission |
allow-modals | Allows to open modal windows |
allow-orientation-lock | Allows to lock the screen orientation |
allow-pointer-lock | Allows to use the Pointer Lock API |
allow-popups | Allows popups |
allow-popups-to-escape-sandbox | Allows popups to open new windows without inheriting the sandboxing |
allow-presentation | Allows to start a presentation session |
allow-same-origin | Allows the iframe content to be treated as being from the same origin |
allow-scripts | Allows to run scripts |
allow-top-navigation | Allows the iframe content to navigate its top-level browsing context |
allow-top-navigation-by-user-activation | Allows the iframe content to navigate its top-level browsing context, but only if initiated by user |
Meer voorbeelde
Voorbeeld
'n <iframe>-sandbak wat vormindiening toelaat:
<iframe src="demo_iframe_sandbox_form.htm" sandbox="allow-forms"></iframe>
Voorbeeld
'n <iframe> sandbox wat skrifte toelaat:
<iframe src="demo_iframe_sandbox_origin.htm" sandbox="allow-scripts"></iframe>
❮ HTML <iframe> tag