このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

HTMLIFrameElement: browsingTopics プロパティ

Deprecated
To be removed

This feature is pending removal from browsers. Using it now may lead to broken functionality in future updates. Following the announcement that Chrome will maintain its current approach to third-party cookies, Chrome decided to withdraw certain Privacy Sandbox features including the topics API.

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

非標準: この機能は標準化されていません。非標準の機能はブラウザーの対応が限られ、将来的に変更または削除される可能性があるため、本番環境での使用は推奨されません。ただし、標準の選択肢が存在しない特定のケースでは、有効な代替手段となる場合があります。

警告: この機能は現在、2 つのブラウザーベンダーから反対されています。反対の詳細については、標準の位置づけの節をご覧ください。

browsingTopicsHTMLIFrameElement インターフェイスのプロパティで、関連付けられた <iframe> のソースに対するリクエストとともに、現在のユーザーが選択したトピックを Sec-Browsing-Topics ヘッダーで送信すべきであることを指定する論理値です。これは、HTML の browsingtopics 属性を反映しています。

詳しくはトピック API の使用を参照してください。

論理値。既定値は false です。関連付けられた <iframe> のソースリクエストを、現在のユーザーが選択したトピックを含む Sec-Browsing-Topics ヘッダーとともに送信するには、これを true に設定します。

取得

browsingtopicstrue に設定し、宣言的に <iframe> コンテンツを読み込みます。

html
<iframe browsingtopics title="Advertising container" src="adtech1.example">
  ...
</iframe>

スクリプトを使用して browsingTopics の値をログ出力します。

js
const iframeElem = document.querySelector("iframe");
console.log(iframeElem.browsingTopics); // 対応しているブラウザーでは true が返る

設定

最小限の <iframe> を指定します。

html
<iframe> ... </iframe>

browsingtopicstrue に設定し、スクリプト経由で <iframe> コンテンツを読み込みます。

js
const iframeElem = document.querySelector("iframe");

iframeElem.browsingTopics = true;
iframeElem.title = "Advertising container";
iframeElem.src = "adtech1.example";

仕様書

この機能は公式標準の一部ではありませんが、トピック API 非公式提案草案で定義されています。

ブラウザーの互換性

関連情報