I created a very simple site to create a popup on my second screen.
The Multi-Screen Window Placement Api promises to do the trick, but i am not able to make it work.
I get all the informations about both screens, but cant open the popup on the correct display.
Does anyone have an idea? Is it because of the "window-placement" permission or something?
Here is the simple site I made:
<!DOCTYPE html>
<html>
<title>Window Placement</title>
<head>
<script type="text/javascript">
let url = "file:///C:/Users/path/to/file.html";
let x = "1000";
let y = "250";
let width = "250";
let height = "250";
let popup;
async function screenDetails() {
if (window.screen.isExtended) {
console.log("Multiple screens detected");
try {
const screens = await window.getScreenDetails();
let primary;
let second;
for (let element of screens.screens) {
if (element.isPrimary) {
primary = element;
} else {
second = element;
}
}
let features = "left=" + x + ",top=" + y +
",width=" + width + ",height=" + height;
popup = window.open(url, 'Popup', features);
} catch (err) {
console.error(err);
}
} else {
console.log("Single screen detected");
}
}
</script>
</head>
<body>
<button type="button" onclick="open()">Open</button>
</body>
</html>