سمة وضع الحماية لـ HTML <iframe>

❮ علامة HTML <iframe>

مثال

<iframe> مع قيود إضافية:

<iframe src="demo_iframe_sandbox.htm" sandbox></iframe>

المزيد من الأمثلة "جربها بنفسك" أدناه.


التعريف والاستخدام

تتيح السمة sandboxمجموعة إضافية من القيود على المحتوى في إطار iframe.

عندما تكون sandboxالسمة موجودة ، وسوف:

  • تعامل مع المحتوى على أنه من أصل فريد
  • تقديم نموذج الحظر
  • حظر تنفيذ البرنامج النصي
  • تعطيل واجهات برمجة التطبيقات
  • منع الروابط من استهداف سياقات التصفح الأخرى
  • منع المحتوى من استخدام المكونات الإضافية (من خلال <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>