At present, more and more developers connect multiple monitors to work, but have you found that when you open a new window in the browser, it will only be displayed on your current monitor. If you want to place it in a browser , you need to drag the window over, is it possible to open the window directly on the specified display screen?
Usually we can open a window through window.open method, such as:
const popup = window.open( "https://www.baidu.com/", "_blank", "width=400, height=300, left=100, top=100" );
But they are only opened on the current screen, how to make it open the window in the specified display?
01
Multi-Screen Window Placement API
Since Chrome 86, the Multi-Screen Window Placement API has been supported, but it is still in the experimental stage. You can enable #enable-experimental-web-platform-features in chrome://flags
Determine if the browser supports this feature
if ("getScreens" in window) { //支持}
Determine whether to connect to multiple displays
await isMultiScreen()
…
The post js implementing multiscreen/crossscreen window placement first appeared on Lenix Blog .
This article is reprinted from https://blog.p2hp.com/archives/8923
This site is for inclusion only, and the copyright belongs to the original author.