Akshay

Akshay

  • 1.3k
  • 103
  • 34k

New Window Opens on the Primary Screen Instead of the Extended Screen

Feb 8 2025 11:57 AM
const primaryScreenWidth = 1680; // Primary screen width
    const extendedScreenWidth = 2560; // Assume extended screen width (adjust accordingly)
    const windowWidth = 800;
    const windowHeight = 600;

    // Open the window on the extended screen
    const newWindow = window.open(
      '',
      '_blank',
      width=${windowWidth},height=${windowHeight},left=${extendedScreenWidth},top=100
    );

    if (newWindow) {
      setTimeout(() => {
        // Move the window to the extended screen (assume extended screen is on the right)
        newWindow.moveTo(extendedScreenWidth + 100, 100); // Adjust if needed
        newWindow.resizeTo(windowWidth, windowHeight);
        console.log("Window moved to extended screen");
      }, 500);
    } else {
      console.error("Failed to open new window");
    }

my screen size = 1680;

The popup window opens on the primary screen instead of the extended screen. However, if moved manually, it displays correctly on the extended screen.

Additionally, how can I detect an extended screen in Angular?