HTML <iframe> 샌드박스 속성
예시
추가 제한이 있는 <iframe>:
<iframe src="demo_iframe_sandbox.htm" sandbox></iframe>
아래에서 더 많은 "직접 사용해 보기" 예를 살펴보세요.
정의 및 사용
이 sandbox
속성은 iframe의 콘텐츠에 대한 추가 제한 집합을 활성화합니다.
sandbox
속성이 있는 경우 다음을 수행 합니다.
- 고유한 출처의 콘텐츠로 취급
- 블록 양식 제출
- 스크립트 실행 차단
- API 비활성화
- 링크가 다른 브라우징 컨텍스트를 대상으로 하지 못하도록 방지
- 콘텐츠가 플러그인을 사용하지 못하도록 방지(
<embed>
,<object>
,<applet>
또는 기타를 통해) - 콘텐츠가 최상위 브라우징 컨텍스트를 탐색하는 것을 방지
- 자동으로 트리거되는 기능 차단(예: 자동으로 비디오 재생 또는 자동으로 양식 컨트롤에 초점 맞추기)
속성 값은 sandbox
비어 있거나(모든 제한 사항이 적용됨) 특정 제한 사항을 제거할 미리 정의된 값의 공백으로 구분된 목록일 수 있습니다.
브라우저 지원
표의 숫자는 속성을 완전히 지원하는 첫 번째 브라우저 버전을 지정합니다.
Attribute | |||||
---|---|---|---|---|---|
sandbox | 4.0 | 10.0 | 17.0 | 5.0 | 15.0 |
통사론
<iframe sandbox="value">
속성 값
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 |
더 많은 예
예시
양식 제출을 허용하는 <iframe> 샌드박스:
<iframe src="demo_iframe_sandbox_form.htm" sandbox="allow-forms"></iframe>
예시
스크립트를 허용하는 <iframe> 샌드박스:
<iframe src="demo_iframe_sandbox_origin.htm" sandbox="allow-scripts"></iframe>
❮ HTML <iframe> 태그