Document: parseHTMLUnsafe() 静的メソッド

Baseline 2024
Newly available

Since July 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

parseHTMLUnsafe()Document オブジェクトの静的メソッドで、HTML の文字列(宣言的なシャドウルートを含む可能性があるもの)を解釈し、新しい Document インスタンスを生成するために使用します。

メソッド名の接尾辞 "Unsafe" は、 <script> 要素が構文解析中に評価されないのに対し、このメソッドは他にも安全でない可能性のある XSS 関連の入力をサニタイズしないことを示します。

結果として得られる Document は、コンテンツ型が "text/html"、文字セットには UTF-8、URL には "about:blank" が指定されます。

構文

js
Document.parseHTMLUnsafe(input)

引数

html

解釈する HTML の文字列です。

返値

Document です。

例外

なし。

仕様書

Specification
HTML
# dom-parsehtmlunsafe

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
parseHTMLUnsafe() static method

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Has more compatibility info.

関連情報