Activate Fullscreen using mouseover or onmouseover

0

I currently use the following code for the Fullscreen and it works great when using "onclick":

    <p onmouseover="openFS(this) id="mysite"><h2>Fullscreen with JavaScript</h2>
<button onclick="openFS();">Open texto in Fullscreen Mode</button></p>
        <script>
var elem = document.getElementById("mysite");
function openFS() {
  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>

My problem occurs when the function is not activated when using "mouseover" or "onmouseover=" openFS (this) "s", or if there is a way to use if {mouseover} else {onclick} or something like that, I do not really know how it could be achieved, in theory it is what I need. The code is js which is the most used but if it is to use jquery then neither mode but that is as last option.

Awaiting prompt response, and thanking all help in advance.

    
asked by Manuel b 17.11.2018 в 01:59
source

2 answers

0

Try the following code ... Greetings

 

var elem = document.getElementById("mysite");
function openFS() {
  console.log('full');
  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();
  }
}
<div onmouseover="openFS(this)" id="mysite">
<h2>Fullscreen with JavaScript</h2>
<button onclick="openFS()">Open texto in Fullscreen Mode</button>
</div>
    
answered by 17.11.2018 в 02:12
0

Does it print an error in the browser console? (It can be opened from F12 em chrome).

I also tell you ... You have not closed quotes to close the function onmouseover
<p onmouseover="openFS(this)" id="mysite">

    
answered by 17.11.2018 в 02:17