0

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

  • 1
    `msRequestFullscreen` is a function, so `document.documentElement.msRequestFullscreen === true` should be evaluating to false. `document.documentElement.msFullscreenEnabled === true` could evaluate to true... – Heretic Monkey Apr 15 '20 at 13:31
  • Have edited the question accordingly. – akshendra Garg Apr 15 '20 at 13:53
  • So, a function call will return undefined if it is a void function (i.e., it doesn't return anything). This is normal. Does `requestFullScreen()` return something other than undefined in Chrome? – Heretic Monkey Apr 15 '20 at 14:15
  • in chrome it changes it to fulsscreen while returning- Promise {} __proto__: Promise [[PromiseStatus]]: "resolved" [[PromiseValue]]: undefined – akshendra Garg Apr 16 '20 at 06:24

1 Answers1

1

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

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19
  • Yes this code is working on ie 11. My code is not working in ie11- I have correctly replaced var elem = document.getElementById("myvideo"); with var elem = document.getElementById("ember715"); note I have tried my code (with the above replacement ) in chrome and it is working and hence I am sure that I have selected the elem correctly. – akshendra Garg Apr 16 '20 at 06:37
  • If possible, can you post your HTML along with your JS code? So that we can also try to make a test with your code to see the results. It may help to narrow down the issue. – Deepak-MSFT Apr 16 '20 at 07:35