Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
How make chrome.windows.create show the window on the same display?

I am making a chrome extension that opens a popup window upon clicking button injected into the page. Everything works flawlessly apart from the fact that the window is displayed on the main display, and not the one the browser window invoking the popup is on. How can I handle this? Using Mac with custom display arrangement, if that's relevant. I'd like for the window to just refer to boundaries of the window it originated from.

From what I'm understanding this involves some elaborate displays pixel calculation, but how to get display sizes in that context? I hope you see what I'm saying and that I included all relevant details. I'm including my code for opening the window below:

    chrome.windows.getCurrent((tabWindow) => {
        const popupWidth = 400;
        const popupHeight = 400;
        const leftOffset = (tabWindow.width/2)-(popupWidth/2);
        const topOffset = (tabWindow.height/3)-(popupHeight/2); 

        var infoPopupUrl = "someurl";

        chrome.windows.create(
            {
                'url': chrome.runtime.getURL(infoPopupUrl),
                'type': "popup",
                'width': popupWidth,
                'height': popupHeight,
                'left': Math.round(leftOffset),
                'top': Math.round(topOffset),
                'focused': true
            }
        );
    });

Thanks everyone for the help.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This link: https://stackoverflow.com/a/25830431/3218811

Led me to finding answer in the screen object. There are availLeft and availTop properties that represent the exact relations of screens arrangements. Works on Mac, I have to test other platforms, but I suppose it's standard in Chrome:

        const leftOffset = (tabWindow.width/2)-(popupWidth/2)+screen.availLeft;        
        const topOffset = (tabWindow.height/3)-(popupHeight/2)+screen.availTop; 
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!