-2

I'm wondering if it is at all possible to use JavaScript to detect if the user's browser is minimized (not completely minimized -- just reduced size to smaller then maximize) at all, and if it is then > force full screen > upon page load of website.

$( document ).ready(function() {
   if (smaller then max screen) {
   screen = 100%; // general idea
});
Dr Upvote
  • 8,023
  • 24
  • 91
  • 204
  • _“upon page load of website (as soon as URL is accessed)”_ – how would that even happen, if the browser is minimized? – CBroe Jun 18 '15 at 17:51
  • 4
    I personally dislike *all* websites that maximize themselves -- I want to be in control of the size of my windows. That said, go here for maximization: http://stackoverflow.com/questions/10297168/how-to-open-maximized-window-with-javascript and here for detecting minimization: http://stackoverflow.com/questions/10328665/how-to-detect-browser-minimize-and-maximize-state-in-javascript – userbd Jun 18 '15 at 17:54
  • 3
    As I think you already know, this is bad ux. Why do you think the user will need full screen forced on them? What does the page show? – Chris Charles Jun 18 '15 at 17:54
  • 2
    maximized is different than full screen. You won't be able to switch to true full screen without user intervention because of security concerns. (Imagine that a full screen window mimicked the desktop and requested credentials) – Stephen Thomas Jun 18 '15 at 17:56
  • 1
    Please, don't use this. It is fine as a project, but it will be trully annoying for the general public, and it would make your site have a terribly bad reputation. – Ismael Miguel Jun 18 '15 at 18:00
  • Well I was mostly just curious. – Dr Upvote Jun 18 '15 at 18:01
  • @Cbroe terminology typo, has been updated. – Dr Upvote Jun 18 '15 at 18:32

1 Answers1

2

Yes it is possible to detect change of size, here's how to do it,using jQuery:

$(window).resize(function() {
  //...
});

And here's how to maximize the browser window :

window.moveTo(0, 0);
window.resizeTo(screen.availWidth, screen.availHeight);

But really, I would not encourage it, as it's better that the user controls the browsing experience.

Dhruv Ramani
  • 2,633
  • 2
  • 22
  • 29
  • 3
    As a sidenote, `window.resizeTo` and `window.moveTo` are controlled by browser options, user can choose, if a web page can use these methods. – Teemu Jun 18 '15 at 17:59
  • 1
    Thanks @Teemu.In chrome, how do I disable the use of `window.resizeTo` and `window.moveTo`? – Dhruv Ramani Jun 18 '15 at 18:03