Is there any way to detect the second monitor / screen with Javascript?

4

I would like to know if there is any way to detect the existence of a second monitor with Javascript.

In a scenario where I was using two monitors / screens on my computer, I would like to open a popup through window.open and move it to a second monitor / screen, in full size.

Would it be possible to do this with Javascript?

I know that there may not be anything native, but maybe there should be some ingenious, calculating way to detect it.

I've been taking a lookup and I've seen that the object window.screen seems bring some interesting information about the user's monitor / screen.

Would that be the way?

    
asked by anonymous 22.05.2018 / 20:18

1 answer

2

It does not exist, it is almost impossible to move to the second screen , there should be half a dozen gambiarras out there saying it works, but it is not something that responds correctly, browser, but mainly operating system operating system.

Things like calculating the width and trying to set the no left of window.open will not work. Perhaps in older systems, maybe Windows XP works, but today the multi-screen system is "more complex," so even though theoretically you can detect that there is a second screen (how to calculate the ratio to assume that this is not a conventional measure ) you would not be able to programmatically move it to the second screen.

What really is missing is a native JavaScript API that does this in a simple way, in fact I must say that even window.open might have improved somewhat maintaining a backward compatibility for legacy codes, but I really do not believe that this is of interest.

I'll confess, the same need you have to control a window to be displayed on another screen I've had, so many were the difficulties with the browser limitations and JavaScript APIs that I made a simple and unique decision: I migrated to the Qt , initially using QtWebkit and later QtWebEngine (Chrome technology). So I created a JavaScript interface that communicated with the software, so I made a monitors / screen control available myself. My need was simple, the system opens in the browser that I created and within the system had a link display product for the client, which should display on the monitor that is on each table only the product, and that is how I came to the only viable solution , because I think that to create websites monitors control is really expendable and if it is to use in an internal system then you should think of a solution less "WEB", at least in the case of this specific situation, since to display in another screen really 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 , that's not it, I understand there's a lot of people on the web for convenience, to run the application on multiple devices, but there are solutions to the HTML and JavaScript world in an easy and uncomplicated way, without having to appeal to things like C ++, Python, Java and being forced to learn something new, a great example of 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
23.05.2018 / 15:12