There is no, it is almost impossible to move to the second screen, must have a half dozen gambiarras that promote around claiming to work, but it is not something that responds correctly, ranging not only from browser to browser, but mainly from operating system to operating system.
Things like calculating width and trying to define the left
of window.open
won’t work. Maybe on older systems, maybe on Windows XP it works, but today the system of multiple screens is "more complex", so even if theoretically you can detect that there is a second screen (how to calculate the ratio to assume that it is not a conventional measure) you would not be able to do the move to the second screen in a programmed way.
What is really missing is a native Javascript API that does this in a simple way, in fact I must say that even window.open
could have improved a little by maintaining a backward compatibility for legacy codes, but really I don’t think this is of interest.
I’ll confess to you, the same need that you have to control a window to be displayed on another screen I had, so many difficulties with the limitations of browsers and Javascript Apis that I made a simple and unique decision: migrated to the Qt
, initially using QtWebkit
and subsequently QtWebEngine
(chrome technology). So I created a Javascript interface that communicated with the software, so I made a monitor/screen control available myself. My need was simple, the system opens in the browser that I created and within the system had a product display link to the customer, which should display on the monitor that sits on each table only the product, and that’s how I arrived at the only viable solution, because I think that to create monitor control websites is really dispensable and if it is to use in an internal system then you should think of a less "WEB" solution, at least in the case of this specific situation, since displaying on another screen really seems like a very specific need and probably wouldn’t be for all users.
I’m not just saying, run for the mountains, abandon the WEB, not that, I understand that there are many people who are on the web for the practicality, for the ease of running the application on several devices, but there are solutions to the world HTML and Javascript 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 various platforms.
High-use applications use such technology, such as:
- Github Desktop
- Skype
- Atom
- Visualstudio Code
PS: Do not edit screen, because I put to help who is from Portugal :p
– Wallace Maxters
I don’t think there’s any way to actually detect for sure the existence of two monitors, but here at MSDN, they cited that
screen.width > (screen.height * 1.78)
, probably the user is with two monitors side by side as it results in an aspect greater than 16:9. But it also doesn’t work if there are two monitors on top of each other.– Artur Trapp
@Arturotemplário, there is currently the widescreen that has the ratio of 21:9, is a monitor only.
– bio