HTMLIFrameElement: thuộc tính contentDocument
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Nếu iframe và tài liệu cha của iframe có cùng nguồn gốc, trả về một Document (tức là tài liệu đang hoạt động trong ngữ cảnh duyệt web lồng ghép của khung nội tuyến), ngược lại trả về null.
Ví dụ về contentDocument
js
const iframeDocument = document.querySelector("iframe").contentDocument;
iframeDocument.body.style.backgroundColor = "blue";
// Dòng này sẽ chuyển iframe thành màu xanh dương.
Đặc tả kỹ thuật
| Specification |
|---|
| HTML> # dom-iframe-contentdocument> |