akshendra Garg
akshendra Garg

Reputation: 51

document.documentElement.msRequestFullscreen() returns undefined

I am trying to go fullscreen using document.documentElement.msRequestFullscreen() on ie11. It returns undefined.

Also

var elem = document.getElementById("ember715"); 
elem.msRequestFullscreen()

returns undefined on ie11. P.S- elem.requestFullscreen() does the job in chrome so elem is properly defined. I have borrowed the idea from How to enable IE full-screen feature like firefox and chrome

Upvotes: 0

Views: 1227

Answers (1)

Deepak-MSFT
Deepak-MSFT

Reputation: 11335

I suggest you make a test with the code below. I tested it with IE 11 and it works fine.

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>

<h2>Fullscreen with JavaScript</h2>
<p>Click on the button to open the video in fullscreen mode.</p>
<button onclick="openFullscreen();">Open Video in Fullscreen Mode</button>
<p><strong>Tip:</strong> Press the "Esc" key to exit full screen.</p>

<video width="100%" controls id="myvideo">
  <source src="https://www.w3schools.com/jsref/rain.mp4" type="video/mp4">
  <source src="sample.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>

<script>
/* Get the element you want displayed in fullscreen */ 
var elem = document.getElementById("myvideo");

/* Function to open fullscreen mode */
function openFullscreen() {
  if (elem.requestFullscreen) {
  elem.requestFullscreen();
  } else if (elem.mozRequestFullScreen) { /* Firefox */
  elem.mozRequestFullScreen();
  } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari & Opera */
  elem.webkitRequestFullscreen();
  } else if (elem.msRequestFullscreen) { /* IE/Edge */
  elem.msRequestFullscreen();
  }
}
</script>

<p>Note: Internet Explorer 10 and earlier does not support fullscreen mode.</p>

</body>
</html>

Reference:

HTML DOM requestFullscreen() Method

Upvotes: 2

Related Questions