Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function makeFrame() {
- ifrm = document.createElement("IFRAME");
- ifrm.setAttribute("src", "#");
- ifrm.setAttribute("id", "main_frame");
- ifrm.style.width = '100%';
- ifrm.style.height = '100%';
- ifrm.style.border = 'none';
- ifrm.style.display = 'none';
- document.body.appendChild(ifrm);
- }
- function goFullscreen() {
- const button_FS = localStorage.getItem('FullScreen');
- if(button_FS == 'Inativo' || button_FS == null){
- makeFrame();
- const mf = document.getElementById("main_frame");
- if ((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)) {
- if (mf.requestFullScreen) {
- mf.requestFullScreen();
- } else if (mf.mozRequestFullScreen) {
- mf.mozRequestFullScreen();
- } else if (mf.webkitRequestFullScreen) {
- mf.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
- } else if (mf.msRequestFullscreen) {
- mf.msRequestFullscreen();
- }
- mf.style.display="block";
- localStorage.setItem("FullScreen","Ativo");
- }
- }else if(button_FS == 'Ativo'){
- ////// SÓ FUNCIONA COM O ALERT() AQUI ////////////
- const mf = document.getElementById("main_frame");
- //mf.style.display="none";
- var xframe = document.getElementById("main_frame");
- xframe.parentNode.removeChild(xframe);
- localStorage.setItem("FullScreen","Inativo");
- }
- }
- function fullscreenChanged() {
- if (document.webkitFullscreenElement == null) {
- const mf = document.getElementById("main_frame");
- mf.style.display="none";
- var xframe = document.getElementById("main_frame");
- xframe.parentNode.removeChild(xframe);
- localStorage.setItem("FullScreen","Inativo");
- }
- }
- document.onwebkitfullscreenchange = fullscreenChanged;
- $(document).ready(function(){
- $('#btn_FS').on('click', function(){
- goFullscreen();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement