Automatic Click along with full screen

5

I have a site, and on the site the user when they log in will go to a page and that page should be full screen automatically without the user needing to click something.

I read that it is not possible for the browser to be full screen without the user's permission, so I thought I would put an automatic click on the site as soon as the user logs in, but still does not leave.

The code I have:

JS:

document.getElementById('teste').click();

    function toggleFullScreen() {
  if (!document.fullscreenElement &&    // alternative standard method
      !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) {  // current working methods
    if (document.documentElement.requestFullscreen) {
      document.documentElement.requestFullscreen();
    } else if (document.documentElement.msRequestFullscreen) {
      document.documentElement.msRequestFullscreen();
    } else if (document.documentElement.mozRequestFullScreen) {
      document.documentElement.mozRequestFullScreen();
    } else if (document.documentElement.webkitRequestFullscreen) {
      document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
    }
  } else {
    if (document.exitFullscreen) {
      document.exitFullscreen();
    } else if (document.msExitFullscreen) {
      document.msExitFullscreen();
    } else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    } else if (document.webkitExitFullscreen) {
      document.webkitExitFullscreen();
    }
  }
}

HTML:

<button id="teste" onClick="toggleFullScreen();"></button>

Is there any way I can do this that I need?

    
asked by anonymous 06.06.2018 / 14:55

2 answers

2
This is impractical, first because if it were possible I would as a user would refuse to browse various sites, which would use this indiscriminately, many lay users would get lost without knowing what to do or irritated, the API itself is determined to being thus, the user decides what he wants and what is better for him.

Forcing an automatic click will also not work , the browser knows very well the difference of when the click is simulated via JS and when it is done by the user (or software that simulates the user) .

The browser is the user, so the intention to use a browser is to be able to use the tabs and windows, in fact with the pardon of the word, but this to force the fullscreen is perfumery, browsers are not final software for exclusive use , the premise is the same as I answered in:

I'm going to get the part that matters to me:

  

... if it is to use on an internal system (company system)   then you should think of a less "WEB" solution, at least in case   this situation specifies, since displaying on another screen actually   seems a very specific need and probably would not be for   all users.

     

I'm not just saying, run to the mountains, leave the WEB , it's not that, I understand there are a lot of people who are on the web by   practicality, for the ease of running the application in   devices, but there are solutions to the HTML and JavaScript world of   easy and uncomplicated way, without having to appeal to things like   C ++, Python, Java and being forced to learn something new, an example   Great thing about this is Electron:

     

With it it is possible to create desktop applications with HTML technologies, css,   js and that will run on several platforms.

     

High-use applications use such technology, such as:

     
  • Github Desktop

  •   
  • Skype

  •   
  • Atom

  •   
  • VisualStudio Code

  •   
So simply if you want to create enterprise software and limit user access to this software, eletron or a platform that uses webViews, such as Qt, or those "derivatives" with WebKit (technology used on safari and some mobiles) such as WebkitGTK + (Qt is C ++, GTK is C but you will probably be able to use it with C ++), of course the Eletron for whom more Web is going to be a path much less painful.

Electron fullscreen

An example I found in this link link , should look like this:

const {BrowserWindow} = require('electron')

let win = new BrowserWindow({ fullscreen: true })
win.on('closed', () => {
    win = null
})

win.loadURL('https://seusite.com/login')

To create the "deploy", read this:

For Windows and Mac OSX things are different

    
11.06.2018 / 23:29
0

Instead of using <button> use this event in your HTML:% <body onClick="toggleFullScreen();">
This means that if the user clicks any part of the screen the FullScreen mode will be activated. This is the simplest way to not have to see this error:
Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.

Another solution I found was:

var src = "https://google.com.br";
window.open(src,"newWin","width="+screen.availWidth+",height="+screen.availHeight);

But in this case the browser will open a new maximized window, I know that's not what you want, but I'm searching.

    
06.06.2018 / 19:47