Setting full screen iframe in JavaScript?

Following is the code for setting full screen iframe in JavaScript −


 Live Demo

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   .result {
      font-weight: 500;
      font-size: 18px;
      color: blueviolet;
   .fullScreen {
      width: 100vw;
      height: 100vh;
<h1>Setting full screen iframe</h1>
<iframe class="frame" src="" width="300px" height="200px"
<button class="Btn" style="margin: 15px;">Fullscreen</button>
<h3>Click on the above button to make the iframe go fullscreen</h3>
   let BtnEle = document.querySelector(".Btn");
   let frameEle = document.querySelector(".frame");
   BtnEle.addEventListener("click", () => {
      frameEle.className = "fullScreen";


On clicking the ‘Fullscreen’ button −