HTMLIFrameElement: thuộc tính browsingTopics

Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Warning: Tính năng này hiện đang vấp phải sự phản đối từ hai nhà phát triển trình duyệt. Xem phần Vị trí tiêu chuẩn để biết chi tiết về sự phản đối.

Thuộc tính browsingTopics của giao diện HTMLIFrameElement là một boolean chỉ định rằng các chủ đề đã chọn cho người dùng hiện tại sẽ được gửi cùng yêu cầu cho nguồn của <iframe> liên kết thông qua tiêu đề Sec-Browsing-Topics. Thuộc tính này phản ánh thuộc tính HTML browsingtopics.

Xem Sử dụng Topics API để biết thêm chi tiết.

Giá trị

Một boolean. Giá trị mặc định là false; đặt thành true để gửi yêu cầu nguồn <iframe> liên kết với tiêu đề Sec-Browsing-Topics chứa các chủ đề đã chọn cho người dùng hiện tại.

Ví dụ

Get

Đặt browsingtopics thành true rồi tải nội dung <iframe> một cách khai báo:

html
<iframe browsingtopics title="Advertising container" src="ad-tech1.example">
  ...
</iframe>

Ghi lại giá trị browsingTopics qua script:

js
const iframeElem = document.querySelector("iframe");
console.log(iframeElem.browsingTopics); // sẽ trả về true trong các trình duyệt hỗ trợ

Set

Chỉ định một <iframe> tối thiểu:

html
<iframe> ... </iframe>

Đặt browsingtopics thành true rồi tải nội dung <iframe> qua script:

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

iframeElem.browsingTopics = true;
iframeElem.title = "Advertising container";
iframeElem.src = "ad-tech1.example";

Đặc tả kỹ thuật

Tính năng này không phải là một phần của bất kỳ tiêu chuẩn chính thức nào, mặc dù nó được chỉ định trong Topics API Unofficial Proposal Draft.

Tương thích trình duyệt

Xem thêm