Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

padamghimire75@gmail.com's avatar

Open new tab on extended screen?

How to open new chrome tab on extended screen while clicking a button?

0 likes
9 replies
kokoshneta's avatar

What do you mean by “open new chrome tab on extended screen”?

Why do you specify a Chrome tab? What if the user isn’t using Chrome at all? Do you just mean a browser tab (or window)?

What is an extended screen? Are you talking about opening a link in a new window and having that window appear on a secondary monitor if the user has multiple monitors hooked up to their computer?

kokoshneta's avatar
Level 27

@padamghimire75@gmail.com There’s no feasible, reliable way to do that. Crucially, the browser does not have direct access to an array of screens plugged in, the way the OS itself does. For that reason, you have no way of knowing how many screens the user actually has, nor how they’re positioned in relation to each other – you can only make assumptions and guesses..

This old StackExchange question has a JavaScript workaround that sort-of-kind-of works, but even that assumes that there are exactly two screens, both with the same resolution, positioned so that screen 2 is immediately to the right of screen 1.

But what if screen 2 were instead to the left of screen 1? Or below it? Or if there were six screens lined up diagonally? If there are 3+ screens, which one would you even want the link to open in? There are just too many variables.

padamghimire75@gmail.com's avatar

@kokoshneta I modified this code because it is throwing window.leftScreenBoundry() is not a function but it is not working

function FindLeftScreenBoundry()
{
    if (window.screenLeft + window.outerWidth > window.screen.width)
    {
        return window.screenLeft - ((window.screenLeft + window.outerWidth) - window.screen.width);
    }

    if (window.screenLeft < 0 && window.screenLeft > (window.screen.width * -1))
    {
        return (window.screen.width * -1);
    }
    return 0;
}

window.leftScreenBoundry = FindLeftScreenBoundry;

Please or to participate in this conversation.