<h1>Responsive iframes — basic example</h1>
<iframe src="frame.html"></iframe>Window: requestResize() method / notebook
Window: requestResize() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
iframe {
frame-sizing: content-block-size;
border: 2px solid gray;
}<head>
<!-- ... -->
<meta name="responsive-embedded-sizing" />
<!-- ... -->
</head>
<body>
<div tabindex="0">
<h1>This is my frame</h1>
<p>This is the content of my discontent.</p>
<p>This is some more content.</p>
</div>
<script>
/* ... */
</script>
</body>const divElem = document.querySelector("div");
divElem.addEventListener("click", addParagraph);
window.addEventListener("keydown", addParagraph);function addParagraph() {
const para = document.createElement("p");
para.textContent = "New content.";
divElem.appendChild(para);
window.requestResize();
}