Create button to cancel fullscreen function

Asked

Viewed 75 times

0

I want to create a button to cancel a fullscreen event/function without toogle function just click the button and close full screen mode.

someone can help me ?

1 answer

0

I managed to solve my problem with the Javascript

Solution:

   <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>

    <script>


function exitFullscreen() {

        if(document.exitFullscreen) {
            document.exitFullscreen(); }

        else if(document.mozCancelFullScreen) {
            document.mozCancelFullScreen();}

        else if(document.webkitExitFullscreen) {
            document.webkitExitFullscreen();
        }
    }
    </script>



html:

    <button class="fechar" onclick="exitFullscreen();"> X </button>
  • Just pointing out that the use of jQuery is optional.

  • Thanks, @Valdeir Psr , I’m new I was trying to make the codes visible. As an added demo ?

  • Just select all the code and press Ctrl + K

  • didn’t work, I did as you said

  • You must select only the code. Or you can insert 4 spaces in each row; or you can still click the icon {}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.