iframe
要素Support in all current engines.
Support in all current engines.
src
— リソースのアドレスsrcdoc
— iframe
内でレンダリングする文書name
— ネストされたブラウジングコンテキスト名sandbox
— ネストされたコンテンツのセキュリティルールallow
— iframe
のコンテンツに適用されるパーミッションポリシーallowfullscreen
— iframe
のコンテンツにrequestFullscreen()
の使用を許可するかどうかwidth
— 横の次元height
— 縦の次元referrerpolicy
— 要素によって開始されたフェッチのためのリファラーポリシーloading
— 読み込み延期を決定するときに使用[Exposed =Window ]
interface HTMLIFrameElement : HTMLElement {
[HTMLConstructor ] constructor ();
[CEReactions ] attribute USVString src ;
[CEReactions ] attribute DOMString srcdoc ;
[CEReactions ] attribute DOMString name ;
[SameObject , PutForwards =value ] readonly attribute DOMTokenList sandbox ;
[CEReactions ] attribute DOMString allow ;
[CEReactions ] attribute boolean allowFullscreen ;
[CEReactions ] attribute DOMString width ;
[CEReactions ] attribute DOMString height ;
[CEReactions ] attribute DOMString referrerPolicy ;
[CEReactions ] attribute DOMString loading ;
readonly attribute Document ? contentDocument ;
readonly attribute WindowProxy ? contentWindow ;
Document ? getSVGDocument ();
// also has obsolete members
};
iframe
要素は、そのネストされたブラウジングコンテキストを表す。
src
属性は、その要素のネストされたブラウジングコンテキストが含まれるページのURLを与える。属性が存在する場合、潜在的にスペースで囲まれた妥当な空でないURLでなければならない。itemprop
属性がiframe
要素で指定される場合、src
も指定されなければならない。
Support in all current engines.
srcdoc
属性は、その要素のネストされたブラウジングコンテキストが含まれるページのコンテンツを与える。属性の値は、iframe
srcdoc
文書のソースである。
srcdoc
属性が存在する場合、指定された順序で、次の構文上のコンポーネントを構成するHTML構文を使用した値を持たなければならない:
上記の要件は、同様にXML文書で当てはまる。
ここでブログは、ブログの記事のコメントで、スクリプトインジェクションから追加の保護レイヤーとともに、この機能をサポートするユーザーエージェントのユーザーに提供するため、以下に記載のsandbox
属性と一緒にsrcdoc
属性を使用する:
< article >
< h1 > I got my own magazine!</ h1 >
< p > After much effort, I've finally found a publisher, and so now I
have my own magazine!Isn't that awesome?!The first issue will come
out in September, and we have articles about getting food, and about
getting in boxes, it's going to be great!</ p >
< footer >
< p > Written by < a href = "/users/cap" > cap</ a > , 1 hour ago.
</ footer >
< article >
< footer > Thirteen minutes ago, < a href = "/users/ch" > ch</ a > wrote: </ footer >
< iframe sandbox srcdoc = "<p>did you get a cover picture yet?" ></ iframe >
</ article >
< article >
< footer > Nine minutes ago, < a href = "/users/cap" > cap</ a > wrote: </ footer >
< iframe sandbox srcdoc = "<p>Yeah, you can see it <a href="/gallery?mode=cover&amp;page=1">in my gallery</a>." ></ iframe >
</ article >
< article >
< footer > Five minutes ago, < a href = "/users/ch" > ch</ a > wrote: </ footer >
< iframe sandbox srcdoc = "<p>hey that's earl's table.
<p>you should get earl&amp;me on the next cover." ></ iframe >
</ article >
引用符をエスケープする必要がある方法に注意し(そうでなければsrcdoc
属性が途中で終わるだろう)、サンドボックス化されたコンテンツに記載される生のアンパサンド(たとえば、URL内または文で)が二重にエスケープされる必要がある―最初にsrcdoc
属性を解析するとき、一度アンパサンドが保持されるように、サンドボックスのコンテンツを解析するとき、誤ってもう一度アンパサンドを解析されるの防ぐために。
さらに、DOCTYPEはiframe
srcdoc
文書で任意であり、かつhtml
、head
、およびbody
要素は任意の開始タグを持ち、しかもtitle
要素はiframe
srcdoc
文書でも任意であるため、body
要素のコンテンツだけが構文でリテラルに出現する必要があるため、srcdoc
属性でのマークアップは、文書全体を表すにもかかわらず比較的簡潔にすることができる。他の要素は依然として存在するが、暗に存在するのみである。
HTML構文において、著者は属性の内容を包むためにU+0022 QUOTATION MARK文字(")を使用することを単に覚えておく必要があり、それからすべてのU+0026 AMPERSAND(&)およびU+0022 QUOTATION MARK(")文字をエスケープし、そしてsandbox
属性を指定し、コンテンツの安全な埋め込みを確実にする必要がある。(さらに&quot;ではなく"になるよう、引用符を確実にするために、引用符の前にアンパサンドをエスケープすることを忘れないこと。)
XMLでU+003C LESS-THAN SIGN(<)文字も同様にエスケープする必要がある。属性値正規化を防ぐために、一部のXMLの空白文字―具体的にはU+0009 CHARACTER TABULATION(tab)、U+000A LINE FEED(LF)、U+000D CARRIAGE RETURN(CR)―もまたエスケープする必要がある。[XML]
src
属性とsrcdoc
属性が両方ともに指定される場合、srcdoc
属性が優先される。これは、著者にsrcdoc
属性をサポートしないレガシーユーザーエージェントに対してフォールバックURLを提供できる。
When an iframe
element element is inserted into a document whose browsing context is non-null, the user agent must run these steps:
Create a new nested browsing context for element.
If element has a sandbox
attribute, then parse the sandboxing directive given the attribute's value and element's iframe
sandboxing flag set.
Process the iframe
attributes for element, with initialInsertion set to true.
When an iframe
element is removed from a document, the user agent must discard the element's nested browsing context, if it is not null, and then set the element's nested browsing context to null.
This happens without any unload
events firing (the element's nested browsing context and its Document
are discarded, not unloaded).
Whenever an iframe
element with a non-null nested browsing context has its srcdoc
attribute set, changed, or removed, the user agent must process the iframe
attributes.
Similarly, whenever an iframe
element with a non-null nested browsing context but with no srcdoc
attribute specified has its src
attribute set, changed, or removed, the user agent must process the iframe
attributes.
To process the iframe
attributes for an element element, with an optional boolean initialInsertion (default false):
If element's srcdoc
attribute is specified, then:
Set element's current navigation was lazy loaded boolean to false.
If the will lazy load element steps given element return true, then:
Set element's lazy load resumption steps to the rest of this algorithm starting with the step labeled navigate to the srcdoc resource.
Set element's current navigation was lazy loaded boolean to true.
Start intersection-observing a lazy loading element for element.
Return.
Navigate to the srcdoc resource: navigate an iframe
or frame
given element and a new response whose URL list is « about:srcdoc
», header list is « (`Content-Type
`, `text/html
`) », and body is the value of element's srcdoc
attribute.
The resulting Document
must be considered an iframe
srcdoc
document.
Otherwise, run the shared attribute processing steps for iframe
and frame
elements given element and initialInsertion.
The shared attribute processing steps for iframe
and frame
elements, given an element element and a boolean initialInsertion, are:
Let url be the URL record about:blank
.
If element has a src
attribute specified, and its value is not the empty string, then parse the value of that attribute relative to element's node document. If this is successful, then set url to the resulting URL record.
If there exists an ancestor browsing context of element's nested browsing context whose active document's URL, ignoring fragments, is equal to url, then return.
If url matches about:blank
and initialInsertion is true, then:
Perform the URL and history update steps given element's nested browsing context's active document and url.
This is necessary in case url is something like about:blank?foo
. If url is just plain about:blank
, this will do nothing.
Run the iframe load event steps given element.
Return.
Let resource be a new request whose URL is url and whose referrer policy is the current state of element's referrerpolicy
content attribute.
If element is an iframe
element, then set element's current navigation was lazy loaded boolean to false.
If element is an iframe
element, and the will lazy load element steps given element return true, then:
Set element's lazy load resumption steps to the rest of this algorithm starting with the step labeled navigate to the resource.
Set element's current navigation was lazy loaded boolean to true.
Start intersection-observing a lazy loading element for element.
Return.
Navigate to the resource: navigate an iframe
or frame
given element and resource.
To navigate an iframe
or frame
given an element element and a resource resource:
Let historyHandling be "default
".
If element's nested browsing context's active document is not completely loaded, then set historyHandling to "replace
".
Let reportFrameTiming be the following step given response response: queue an element task on the networking task source given element's node document's relevant global object to finalize and report timing given response, element's node document's relevant global object, and element's local name.
Navigate element's nested browsing context to resource, with historyHandling set to historyHandling, the source browsing context set to element's node document's browsing context, and processResponseEndOfBody set to reportFrameTiming.
A load
event is also fired at the iframe
element when it is created if no other data is loaded in it.
Each Document
has an iframe load in progress flag and a mute iframe load flag. When a Document
is created, these flags must be unset for that Document
.
To run the iframe load event steps, given an iframe
element element:
Assert: element's nested browsing context is not null.
Let childDocument be the active document of element's nested browsing context.
If childDocument has its mute iframe load flag set, then return.
Set childDocument's iframe load in progress flag.
Fire an event named load
at element.
Unset childDocument's iframe load in progress flag.
This, in conjunction with scripting, can be used to probe the URL space of the local network's HTTP servers. User agents may implement cross-origin access control policies that are stricter than those described above to mitigate this attack, but unfortunately such policies are typically not compatible with existing web content.
If an element type potentially delays the load event, then for each element element of that type, the user agent must delay the load event of element's node document if element's nested browsing context is non-null and any of the following are true:
element's nested browsing context's active document is not ready for post-load tasks.
Anything is delaying the load event of element's nested browsing context's active document.
element's nested browsing context is in the delaying load
events mode.
If, during the handling of the load
event, element's nested browsing context is again navigated, that will further delay the load event.
Each iframe
element has an associated current navigation was lazy loaded boolean, initially false. It is set and unset in the process the iframe
attributes algorithm.
An iframe
element whose current navigation was lazy loaded boolean is false potentially delays the load event.
要素が作成されるときに、srcdoc
属性が設定されず、src
属性が設定されてない、または設定されるがその値が解析することができないのいずれかの場合、ブラウジングコンテキストは初期のabout:blank
Document
のままになる。
ユーザーがこのページからナビゲートする場合、iframe
のネストされたブラウジングコンテキストのWindowProxy
オブジェクトは、新規Document
オブジェクトに対する新規Window
オブジェクトをプロキシーサーバーに送るが、src
属性は変更されないだろう。
name
属性が存在する場合、妥当なブラウジングコンテキスト名でなければならない。指定された値は、要素のネストされたブラウジングコンテキストが作成されたときに存在する場合、その名前を付けるために使用される。
Support in all current engines.
sandbox
属性が指定された場合、iframe
によってホストされるあらゆるコンテンツに一連の追加の制限が可能になる。その値は、ASCII大文字・小文字不区別である順不同の一意な空白区切りトークンの集合でなければならない。許可される値は次のとおり:
allow-downloads
allow-forms
allow-modals
allow-orientation-lock
allow-pointer-lock
allow-popups
allow-popups-to-escape-sandbox
allow-presentation
allow-same-origin
allow-scripts
allow-top-navigation
allow-top-navigation-by-user-activation
allow-top-navigation-to-custom-protocols
この属性が設定される場合、コンテンツは一意な生成元からのものとして扱われ、フォームやスクリプトは無効となり、リンクは他のブラウジングコンテキストをターゲットすることを防ぎ、プラグインは保護される。allow-same-origin
キーワードは、コンテンツに一意な生成元を強制する代わりに、コンテンツを実際の生成元からのものとして扱わさせる。allow-top-navigation
キーワードは、コンテンツにトップレベルのブラウジングコンテキストをナビゲートすることができる。allow-top-by-user-activation
キーワードは同様に動作するが、ブラウジングコンテキストのアクティブウィンドウがtransient activationを持つ場合にのみそのようなナビゲーションを許可する。allow-top-navigation-to-custom-protocols
により、非フェッチスキームへのナビゲーションが外部ソフトウェアに渡されるようになる。 allow-forms
、allow-modals
、allow-orientation-lock
、allow-pointer-lock
、allow-popups
、allow-presentation
、allow-scripts
およびallow-popups-to-escape-sandbox
キーワードは、フォーム、モーダルダイアログ、スクリーンの向きのロック、ポインターロックAPI、ポップアップ、プレゼンテーションAPI、スクリプトおよびサンドボックス化されない補助ブラウジングコンテキストの作成をそれぞれ再有効にする。allow-downloads
キーワードは、コンテンツでダウンロードを実行可能にする。[POINTERLOCK] [SCREENORIENTATION] [PRESENTATION]
allow-top-navigation
およびallow-top-navigation-by-user-activation
キーワードは、重複するため、両方指定されてはならない。そのような不適合マークアップにおいて、allow-top-navigation
のみが効果を持つ。
同様に、allow-top-navigation
またはallow-popups
のいずれかが指定されている場合、allow-top-navigation-to-custom-protocols
キーワードを指定てはならない。これは冗長となるためである。
サンドボックス化されたコンテンツの内部でalert()
、confirm()
、およびprompt()
を許可するためには、allow-modals
キーワードとallow-same-origin
キーワードの両方を指定する必要があり、かつロードされるURLはトップレベルの生成元と同一生成元である必要がある 。allow-same-origin
キーワードなしで、コンテンツは異なる生成元として扱われ、異なる生成元のコンテンツは単純なダイアログを表示できない。
効果的に完全にサンドボックスを破壊する、iframe
を含むページが埋め込まれたページに簡単にsandbox
属性を削除して再読み込みできるので、埋め込まれたページが同一生成元を持つときに、allow-scripts
およびallow-same-origin
の両方のキーワードを共に設定する。
iframe
要素のネストされたブラウジングコンテキストがナビゲートされるとき、これらのフラグは効果のみを取る。それらを削除する、または全体のsandbox
属性を削除することは、すでに読み込まれたページに影響を与えない。
潜在的に敵対的なファイルは、iframe
要素を含むファイルと同じサーバーから提供されるべきではない。攻撃者がiframe
内よりむしろ、直接敵対コンテンツを単に訪問することをユーザーに納得させることができる場合、敵対コンテンツをサンドボックス化することは、最小限の助けとなる。敵対的なHTMLコンテンツが原因で発生する可能性のある損害を制限するために、それは独立した専用ドメインから提供されるべきである。たとえsandbox
属性の保護なしで、ユーザーが騙されて直接そのページを訪れたとしても、別のドメインを使用することは、ファイル内のスクリプトがサイトを攻撃できないことを保証する。
When an iframe
element's sandbox
attribute is set or changed while it has a non-null nested browsing context, the user agent must parse the sandboxing directive given the attribute's value and the iframe
element's iframe
sandboxing flag set.
When an iframe
element's sandbox
attribute is removed while it has a non-null nested browsing context, the user agent must empty the iframe
element's iframe
sandboxing flag set.
この例において、一部の完全に未知で、潜在的に敵対的な、ユーザーが提供するHTMLコンテンツは、ページに埋め込まれている。コンテンツが別のドメインから配信されているため、コンテンツはすべて通常のクロスサイト制限の影響を受ける。また、埋め込みページはスクリプティング、プラグイン、フォームを無効にし、コンテンツは、任意のフレームやそのもの(または任意のフレーム、またはウィンドウ自身が埋め込み)以外のウィンドウを移動できない。
< p > We're not scared of you! Here is your content, unedited:</ p >
< iframe sandbox src = "https://usercontent.example.net/getusercontent.cgi?id=12193" ></ iframe >
攻撃者が直接そのページへユーザーにアクセスするように納得させる場合、ページがページ内で検出された攻撃に被害を受け易くなるであろうサイトの生成元のコンテキストで実行されないように別のドメインを使用することが重要である。
この例において、別のサイトからガジェットが埋め込まれている。ガジェットは、スクリプトやフォームが有効であり、生成元サンドボックスの制限は解除され、その発信元のサーバーと通信できる。しかし、プラグインおよびポップアップを無効にしたように、サンドボックスは依然として有用であり、したがってマルウェアやその他の脅威に晒されるユーザーのリスクを軽減する。
< iframe sandbox = "allow-same-origin allow-forms allow-scripts"
src = "https://maps.example.com/embedded.html" ></ iframe >
ファイルAに含まれる次の断片を仮定する:
< iframe sandbox = "allow-same-origin allow-forms" src = B ></ iframe >
またファイルBに含まれるiframeを仮定する:
< iframe sandbox = "allow-scripts" src = C ></ iframe >
さらに、ファイルCに含まれるリンクを仮定する:
< a href = D > Link</ a >
この例に対して、すべてのファイルがtext/html
として供給されると仮定する。
このシナリオでは、ページCはすべてのサンドボックスのフラグを設定される。Aでiframe
が無効であり、これがBにおいてiframe
で設定されるallow-scripts
キーワードセットを上書きするので、スクリプトは無効である。フォームのiframeで設定できるように、スクリプトキーワードを上書きするためのスクリプトは、無効になっている。(Bにおける)内側のiframe
は、allow-forms
キーワードセットを設定されないため、フォームもまた無効である。
Aにおけるスクリプトが、AとBですべてのsandbox
属性を削除すると仮定する。これはすぐには何も変わらないだろう。ユーザーがCのリンクをクリックした場合、Bでiframe
にページDを読み込み、リンクはページBが読み込まれたときにAのiframe
内のネストされたブラウジングコンテキストの状態だったため、あたかもBでiframe
がallow-same-origin
とallow-forms
キーワードが設定されていたかのように、ページDは振る舞うだろう。
何が許可されて何が許可されないかについて判断することは非常に困難であるため、一般に、動的に除去したり、sandbox
属性を変更したりすることは賢明でない。
allow
属性は、指定された場合、iframe
のネストされたブラウジングコンテキスト内のDocumentに対するパーミッションポリシーが初期化されるときに使用されるコンテナーポリシーを決定する。その値はシリアライズされたパーミッションポリシーでなければならない。[PERMISSIONSPOLICY]
この例において、iframe
は、オンラインナビゲーションサービスから地図を埋め込むために使用される。allow
属性は、ネストされたコンテキスト内でジオロケーションAPIを有効にするために使用される。
< iframe src = "https://maps.example.com/" allow = "geolocation" ></ iframe >
allowfullscreen
属性は、真偽属性である。指定する場合、iframe
要素のネストされたブラウジングコンテキスト内のDocument
オブジェクトは、任意の生成元から"fullscreen
"機能を使用できるようにするパーミッションポリシーで初期化されることを示す。これは、パーミッションポリシー属性を処理するアルゴリズムによって実施される。[PERMISSIONSPOLICY]
ここで、iframe
はビデオサイトからのプレーヤーを埋め込むために使用される。allowfullscreen
属性はそのビデオをフルスクリーン表示するようなプレーヤーを有効にするために必要とされる。
< article >
< header >
< p >< img src = "/usericons/1627591962735" > < b > Fred Flintstone</ b ></ p >
< p >< a href = "/posts/3095182851" rel = bookmark > 12:44</ a > — < a href = "#acl-3095182851" > Private Post</ a ></ p >
</ header >
< p > Check out my new ride!</ p >
< iframe src = "https://video.example.com/embed?id=92469812" allowfullscreen ></ iframe >
</ article >
allow
もallowfullscreen
もどちらの属性も、要素のノード文書にその機能の使用が許可されない場合、iframe
要素のネストされたブラウジングコンテキストにおいて機能にアクセスを許可することができない。
To determine whether a Document
object document is allowed to use the policy-controlled-feature feature, run these steps:
If document's browsing context is null, then return false.
If document's browsing context's active document is not document, then return false.
If the result of running is feature enabled in document for origin on feature, document, and document's origin is "Enabled
", then return true.
falseを返す。
ネストされたブラウジングコンテキストのアクティブ文書のパーミッションポリシーにのみ影響するため、allow
およびallowfullscreen
属性は、iframe
のネストされたブラウジングコンテキストがナビゲートされるときにのみ有効である。それらを追加または削除しても、すでに読み込まれている文書には影響しない。
iframe
要素は、埋め込まれたコンテンツが特定のサイズをもつ(たとえば単位が明確に定義された次元をもつ)場合、次元属性をサポートする。
指定した初期コンテンツ内容が正常に使用されるかどうかに関わらず、常にネストしたブラウジングコンテキストを作成するので、iframe
要素はフォールバックコンテンツにならない。
referrerpolicy
属性は、リファラーポリシー属性である。その目的は、iframe
属性を処理するときに使用されるリファラーポリシーを設定することにある。[REFERRERPOLICY]
loading
属性は、遅延読み込み属性である。その目的は、ビューポート外にあるiframe
を読み込むためのポリシーを示すことである。
When the loading
attribute's state is changed to the Eager state, the user agent must run these steps:
Let resumptionSteps be the iframe
element's lazy load resumption steps.
If resumptionSteps is null, then return.
Set the iframe
's lazy load resumption steps to null.
Invoke resumptionSteps.
iframe
要素の子孫は何も表さない。(iframe
要素をサポートしないレガシーユーザーエージェントにおいて、コンテンツはフォールバックコンテンツとして機能することができるマークアップとして解析される。)
HTMLパーサーは、テキストとしてiframe
要素の内側のマークアップを扱う。
Support in all current engines.
Support in all current engines.
The IDL attributes src
, srcdoc
, name
, sandbox
, and allow
must reflect the respective content attributes of the same name.
The supported tokens for sandbox
's DOMTokenList
are the allowed values defined in the sandbox
attribute and supported by the user agent.
The allowFullscreen
IDL attribute must reflect the allowfullscreen
content attribute.
HTMLIFrameElement/referrerPolicy
Support in all current engines.
The referrerPolicy
IDL attribute must reflect the referrerpolicy
content attribute, limited to only known values.
The loading
IDL attribute must reflect the loading
content attribute, limited to only known values.
HTMLIFrameElement/contentDocument
Support in all current engines.
The contentDocument
IDL attribute, on getting, must return the iframe
element's content document.
HTMLIFrameElement/contentWindow
Support in all current engines.
The contentWindow
IDL attribute must return the WindowProxy
object of the iframe
element's nested browsing context, if its nested browsing context is non-null, or null otherwise.
広告ブローカーから広告を含めるようにiframe
を使ったページの例は次のとおり:
< iframe src = "https://ads.example.com/?customerid=923513721&format=banner"
width = "468" height = "60" ></ iframe >
embed
要素Support in all current engines.
Support in all current engines.
src
— リソースのアドレスtype
— 埋め込みリソースタイプwidth
— 横の次元height
— 縦の次元[Exposed =Window ]
interface HTMLEmbedElement : HTMLElement {
[HTMLConstructor ] constructor ();
[CEReactions ] attribute USVString src ;
[CEReactions ] attribute DOMString type ;
[CEReactions ] attribute DOMString width ;
[CEReactions ] attribute DOMString height ;
Document ? getSVGDocument ();
// also has obsolete members
};
Depending on the type of content instantiated by the embed
element, the node may also support other interfaces.
embed
要素は外部の(典型的には非HTML)アプリケーションやインタラクティブコンテンツの統合点を提供する。
src
属性は、埋め込まれているリソースのURLを与える。属性が存在する場合、潜在的にスペースで囲まれた妥当な空でないURLを含まなければならない。
著者は、信頼できないリソースの参照を避けるべきである。そのようなリソースは、著者がFlashの"allowScriptAccess"パラメーターなどの機能を使用した場合でも、プラグインのインスタンス化やスクリプトの実行に使用できる。
itemprop
がembed
要素で指定される場合、src
属性も指定されなければならない。
type
属性が存在する場合は、インスタンスを生成するプラグインが選択されるMIMEタイプを提供する。値は妥当なMIMEタイプ文字列でなければならない。type
属性とsrc
属性の両方が存在する場合、type
属性は、src
属性で指定されたリソースの明示的なContent-Typeメタデータと同じ型を指定しなければならない。
While any of the following conditions are occurring, any plugin instantiated for the element must be removed, and the embed
element represents nothing:
The element has neither a src
attribute nor a type
attribute.
The element has a media element ancestor.
The element has an ancestor object
element that is not showing its fallback content.
An embed
element is said to be potentially active when the following conditions are all met simultaneously:
src
attribute set or a type
attribute set (or both).src
attribute is either absent or its value is not the empty string.object
element that is not showing its fallback content.Whenever an embed
element that was not potentially active becomes potentially active, and whenever a potentially active embed
element that is remaining potentially active and has its src
attribute set, changed, or removed or its type
attribute set, changed, or removed, the user agent must queue an element task on the embed task source given the element to run the embed
element setup steps for that element.
The embed
element setup steps for a given embed
element element are as follows:
If another task has since been queued to run the embed
element setup steps for element, then return.
If element has a src
attribute set, then:
Let url be the result of parsing the value of element's src
attribute, relative to element's node document.
If url is failure, then return.
Let request be a new request whose URL is url, client is element's node document's relevant settings object, destination is "embed
", credentials mode is "include
", mode is "navigate
", and whose use-URL-credentials flag is set.
Let processResponseEndOfBody given response res be to finalize and report timing with res, element's node document's relevant global object, and "embed
".
Fetch request, with processResponseEndOfBody set to processResponseEndOfBody, and processResponse set to the following steps given response response:
If another task has since been queued to run the embed
element setup steps for element, then return.
If response is a network error, then fire an event named load
at element, and return.
Let type be the result of determining the type of content given element and response.
Switch on type:
Display no plugin for element.
image/svg+xml
If element's nested browsing context is null, then create a new nested browsing context for element.
Navigate element's nested browsing context to response, with historyHandling set to "replace
" and the source browsing context set to element's node document's browsing context.
element's src
attribute does not get updated if the browsing context gets further navigated to other locations.
element now represents its nested browsing context.
Display a plugin for element, given type and response.
Fetching the resource must delay the load event of element's node document.
Otherwise:
Let type be the value of element's type
attribute.
If type is a type that a plugin supports, then display a plugin for element given type.
Otherwise, display no plugin for element.
To determine the type of the content given an embed
element element and a response response, run the following steps:
If element has a type
attribute, and that attribute's value is a type that a plugin supports, then return the value of the type
attribute.
If the path component of response's url matches a pattern that a plugin supports, then return the type that that plugin can handle.
For example, a plugin might say that it can handle URLs with path components that end with the four character string ".swf
".
If response has explicit Content-Type metadata, and that value is a type that a plugin supports, then return that value.
Return null.
It is intentional that the above algorithm allows response to have a non-ok status. This allows servers to return data for plugins even with error responses (e.g., HTTP 500 Internal Server Error codes can still contain plugin data).
To display a plugin for an embed
element element, given a string type and optionally a response response:
If element's nested browsing context is not null, then:
Discard element's nested browsing context.
Set element's nested browsing context to null.
Find and instantiate an appropriate plugin based on type, replacing any previously-instantiated plugin for element. If response was given, forward it to the plugin.
element now represents this plugin instance.
Once the plugin, and response if given, are completely loaded, queue an element task on the DOM manipulation task source give element to fire an event named load
at element.
To display no plugin for an embed
element element:
If element's nested browsing context is not null, then:
Discard element's nested browsing context.
Set element's nested browsing context to null.
Display an indication that no plugin could be found for element, replacing any previously-instantiated plugin for element.
element now represents nothing.
The embed
element has no fallback content; its descendants are ignored.
Whenever an embed
element that was potentially active stops being potentially active, any plugin that had been instantiated for that element must be unloaded.
When a plugin is to be instantiated but the sandboxed plugins browsing context flag is set on the embed
element's node document's active sandboxing flag set, then the user agent must not instantiate the plugin, and must instead render the embed
element in a manner that conveys that the plugin was disabled.
The embed
element potentially delays the load event.
name
、align
、hspace
、およびvspace
以外の名前空間なしの属性は、その名前がXML互換性があり、ASCII大文字を一切含まない限り、embed
要素で指定されてもよい。これらの属性は、プラグインにパラメーターとして渡される。
大文字の制限がそのような文書に影響しないので、HTML文書内のすべての属性は自動的に小文字を取得する。
4つの例外は、プラグインに送信するパラメーターを超えた副作用を持つ従来の属性を除外するのに適当である。
The user agent should pass the names and values of all the attributes of the embed
element that have no namespace to the plugin used, when one is instantiated.
The HTMLEmbedElement
object representing the element must expose the scriptable interface of the plugin instantiated for the embed
element, if any.
IDL属性src
、およびtype
のそれぞれは、同じ名前の各コンテンツ属性を反映しなければならない。
object
要素Support in all current engines.
Support in all current engines.
data
— リソースのアドレスtype
— 埋め込みリソースタイプname
— ネストされたブラウジングコンテキスト名form
— form
要素とこの要素を関連付けるwidth
— 横の次元height
— 縦の次元[Exposed =Window ]
interface HTMLObjectElement : HTMLElement {
[HTMLConstructor ] constructor ();
[CEReactions ] attribute USVString data ;
[CEReactions ] attribute DOMString type ;
[CEReactions ] attribute DOMString name ;
readonly attribute HTMLFormElement ? form ;
[CEReactions ] attribute DOMString width ;
[CEReactions ] attribute DOMString height ;
readonly attribute Document ? contentDocument ;
readonly attribute WindowProxy ? contentWindow ;
Document ? getSVGDocument ();
readonly attribute boolean willValidate ;
readonly attribute ValidityState validity ;
readonly attribute DOMString validationMessage ;
boolean checkValidity ();
boolean reportValidity ();
undefined setCustomValidity (DOMString error );
// also has obsolete members
};
Depending on the type of content instantiated by the object
element, the node also supports other interfaces.
object
要素は、リソースの型に応じて、画像として、子ブラウジングコンテキストとして、またはプラグインによって処理される外部リソースとしてのいずれかで扱われる、外部リソースを表すことができる。
data
属性は、リソースのURLを指定する。これは存在しなければならず、かつ潜在的にスペースで囲まれた妥当な空でないURLを含まなければならない。
著者は、信頼できないリソースの参照を避けるべきである。そのようなリソースは、著者がFlashの"allowScriptAccess"パラメーターなどの機能を使用した場合でも、プラグインのインスタンス化やスクリプトの実行に使用できる。
type
属性が存在する場合、リソースのタイプを指定する。存在する場合、属性は妥当なMIMEタイプ文字列でなければならない。
name
属性が存在する場合、妥当なブラウジングコンテキスト名でなければならない。指定された値は、該当する場合、かつ要素のネストされたブラウジングコンテキストが作成されたときに存在する場合、要素のネストされたブラウジングコンテキストに名前を付けるために使用される。
Whenever one of the following conditions occur:
object
elements changes to or from showing its fallback content,classid
attribute is set, changed, or removed,classid
attribute is not present, and its data
attribute is set, changed, or removed,classid
attribute nor its data
attribute are present, and its type
attribute is set, changed, or removed,...the user agent must queue an element task on the DOM manipulation task source given the object
element to run the following steps to (re)determine what the object
element represents. This task being queued or actively running must delay the load event of the element's node document.
If the user has indicated a preference that this object
element's fallback content be shown instead of the element's usual behavior, then jump to the step below labeled fallback.
For example, a user could ask for the element's fallback content to be shown because that content uses a format that the user finds more accessible.
If the element has an ancestor media element, or has an ancestor object
element that is not showing its fallback content, or if the element is not in a document whose browsing context is non-null, or if the element's node document is not fully active, or if the element is still in the stack of open elements of an HTML parser or XML parser, or if the element is not being rendered, then jump to the step below labeled fallback.
If the classid
attribute is present, and has a value that isn't the empty string, then: if the user agent can find a plugin suitable according to the value of the classid
attribute, and plugins aren't being sandboxed, then that plugin should be used, and the value of the data
attribute, if any, should be passed to the plugin. If no suitable plugin can be found, or if the plugin reports an error, jump to the step below labeled fallback.
If the data
attribute is present and its value is not the empty string, then:
If the type
attribute is present and its value is not a type that the user agent supports, and is not a type that the user agent can find a plugin for, then the user agent may jump to the step below labeled fallback without fetching the content to examine its real type.
Parse a URL given the data
attribute, relative to the element's node document.
If that failed, fire an event named error
at the element, then jump to the step below labeled fallback.
Let request be a new request whose URL is the resulting URL record, client is the element's node document's relevant settings object, destination is "object
", credentials mode is "include
", mode is "navigate
", and whose use-URL-credentials flag is set.
Fetch request, with processResponseEndOfBody given response res set to finalize and report timing with res, the element's node document's relevant global object, and "object
".
Fetching the resource must delay the load event of the element's node document until the task that is queued by the networking task source once the resource has been fetched (defined next) has been run.
If the resource is not yet available (e.g. because the resource was not available in the cache, so that loading the resource required making a request over the network), then jump to the step below labeled fallback. The task that is queued by the networking task source once the resource is available must restart this algorithm from this step. Resources can load incrementally; user agents may opt to consider a resource "available" whenever enough data has been obtained to begin processing the resource.
If the load failed (e.g. there was an HTTP 404 error, there was a DNS error), fire an event named error
at the element, then jump to the step below labeled fallback.
Determine the resource type, as follows:
Let the resource type be unknown.
If the user agent is configured to strictly obey Content-Type headers for this resource, and the resource has associated Content-Type metadata, then let the resource type be the type specified in the resource's Content-Type metadata, and jump to the step below labeled handler.
This can introduce a vulnerability, wherein a site is trying to embed a resource that uses a particular plugin, but the remote site overrides that and instead furnishes the user agent with a resource that triggers a different plugin with different security characteristics.
If there is a type
attribute present on the object
element, and that attribute's value is not a type that the user agent supports, but it is a type that a plugin supports, then let the resource type be the type specified in that type
attribute, and jump to the step below labeled handler.
Run the appropriate set of steps from the following list:
Let binary be false.
If the type specified in the resource's Content-Type metadata is "text/plain
", and the result of applying the rules for distinguishing if a resource is text or binary to the resource is that the resource is not text/plain
, then set binary to true.
If the type specified in the resource's Content-Type metadata is "application/octet-stream
", then set binary to true.
If binary is false, then let the resource type be the type specified in the resource's Content-Type metadata, and jump to the step below labeled handler.
If there is a type
attribute present on the object
element, and its value is not application/octet-stream
, then run the following steps:
If the attribute's value is a type that a plugin supports, or the attribute's value is a type that starts with "image/
" that is not also an XML MIME type, then let the resource type be the type specified in that type
attribute.
Jump to the step below labeled handler.
If there is a type
attribute present on the object
element, then let the tentative type be the type specified in that type
attribute.
Otherwise, let tentative type be the computed type of the resource.
If tentative type is not application/octet-stream
, then let resource type be tentative type and jump to the step below labeled handler.
If applying the URL parser algorithm to the URL of the specified resource (after any redirects) results in a URL record whose path component matches a pattern that a plugin supports, then let resource type be the type that that plugin can handle.
For example, a plugin might say that it can handle resources with path components that end with the four character string ".swf
".
It is possible for this step to finish, or for one of the substeps above to jump straight to the next step, with resource type still being unknown. In both cases, the next step will trigger fallback.
Handler: Handle the content as given by the first of the following cases that matches:
If the object
element's nested browsing context is non-null, then it must be discarded and then set to null.
If plugins are being sandboxed, then jump to the step below labeled fallback.
Otherwise, the user agent should use the plugin that supports resource type and pass the content of the resource to that plugin. If the plugin reports an error, then jump to the step below labeled fallback.
image/
"If the object
element's nested browsing context is null, then create a new nested browsing context for the element.
If the URL of the given resource does not match about:blank
, then navigate the element's nested browsing context to that resource, with historyHandling set to "replace
" and the source browsing context set to the object
element's node document's browsing context. (The data
attribute of the object
element doesn't get updated if the browsing context gets further navigated to other locations.)
The object
element represents its nested browsing context.
image/
", and support for images has not been disabledIf the object
element's nested browsing context is non-null, then it must be discarded and then set to null.
Apply the image sniffing rules to determine the type of the image.
The object
element represents the specified image.
If the image cannot be rendered, e.g. because it is malformed or in an unsupported format, jump to the step below labeled fallback.
The given resource type is not supported. Jump to the step below labeled fallback.
If the previous step ended with the resource type being unknown, this is the case that is triggered.
The element's contents are not part of what the object
element represents.
If the object
element does not represent its nested browsing context, then once the resource is completely loaded, queue an element task on the DOM manipulation task source given the object
element to fire an event named load
at the element.
If the element does represent its nested browsing context, then an analogous task will be queued when the created Document
is completely finished loading.
Return.
If the data
attribute is absent but the type
attribute is present, and the user agent can find a plugin suitable according to the value of the type
attribute, and plugins aren't being sandboxed, then that plugin should be used. If these conditions cannot be met, or if the plugin reports an error, jump to the step below labeled fallback. Otherwise return; once the plugin is completely loaded, queue an element task on the DOM manipulation task source given the object
element to fire an event named load
at the element.
Fallback: The object
element represents the element's children. This is the element's fallback content. If the element has an instantiated plugin, then unload it. If the element's nested browsing context is non-null, then it must be discarded and then set to null.
When the algorithm above instantiates a plugin, the user agent should pass to the plugin used the names and values of all the attributes on the element, in the order they were added to the element, with the attributes added by the parser being ordered in source order. If the plugin supports a scriptable interface, the HTMLObjectElement
object representing the element should expose that interface. The object
element represents the plugin. The plugin is not a nested browsing context.
Plugins are considered sandboxed for the purpose of an object
element if the sandboxed plugins browsing context flag is set on the object
element's node document's active sandboxing flag set.
Due to the algorithm above, the contents of object
elements act as fallback content, used only when referenced resources can't be shown (e.g. because it returned a 404 error). This allows multiple object
elements to be nested inside each other, targeting multiple user agents with different capabilities, with the user agent picking the first one it supports.
The object
element potentially delays the load event.
form
属性は、明示的にそのフォームの所有者とobject
要素を関連付けるために使用される。
Support in all current engines.
Support in all current engines.
Support in all current engines.
The IDL attributes data
, type
, and name
each must reflect the respective content attributes of the same name.
HTMLObjectElement/contentDocument
Support in all current engines.
The contentDocument
IDL attribute, on getting, must return the object
element's content document.
HTMLObjectElement/contentWindow
Support in all current engines.
The contentWindow
IDL attribute must return the WindowProxy
object of the object
element's nested browsing context, if its nested browsing context is non-null; otherwise, it must return null.
The willValidate
, validity
, and validationMessage
attributes, and the checkValidity()
, reportValidity()
, and setCustomValidity()
methods, are part of the constraint validation API. The form
IDL attribute is part of the element's forms API.
この例において、HTMLページはobject
要素を使用して埋め込まれている。
< figure >
< object data = "clock.html" ></ object >
< figcaption > My HTML Clock</ figcaption >
</ figure >