Getting the display screen resolution

1,298 views
Skip to first unread message

Chethiya Abeysinghe

unread,
Jan 24, 2014, 12:32:43 AM1/24/14
to chromium-...@chromium.org
Hi Devs,

Is there a way to get the screen resolution of the computer display? 

Thanks
 - Chethiya

Chris Naegelin

unread,
Jan 24, 2014, 1:01:49 AM1/24/14
to Chethiya Abeysinghe, chromium-...@chromium.org
With standard javascript

window.screen.availHeight
window.screen.availWidth
All properties:

availHeightSpecifies the height of the screen, in pixels, minus interface features such as the taskbar in Windows.
availWidthSpecifies the width of the screen, in pixels, minus interface features such as the taskbar in Windows.
colorDepthThe bit depth of the color palette available for displaying images in bits per pixel.
heightThe total height of the screen, in pixels.
pixelDepthDisplay screen color resolution (bits per pixel). Firefox exclusive property.
widthThe total width of the screen, in pixels.


Chris Naegelin


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/89815f30-4295-4e9b-832b-56a78cf55a3b%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/groups/opt_out.

Chethiya Abeysinghe

unread,
Jan 24, 2014, 6:40:57 AM1/24/14
to Chris Naegelin, chromium-...@chromium.org
Hi Chris,
Thanks for pointing that out. Really a life saver for what I'm planing to do. It works in the browser action popup. 

Chethiya

Nathan Pierce

unread,
Oct 7, 2022, 8:01:18 AM10/7/22
to Chromium Extensions, Chethiya Abeysinghe, chromium-...@chromium.org, Chris Naegelin
Can anyone recommend how to make "window" available in the service_worker for MV3?

Stefan Van Damme

unread,
Oct 7, 2022, 10:09:04 AM10/7/22
to Chromium Extensions, nors...@gmail.com, Chethiya Abeysinghe, chromium-...@chromium.org, Chris Naegelin
Hi @nors...

The Chrome extension (in Manifest V3) service worker can not have access to the DOM.
A workaround is to try running your window.screen.availHeight code in your content script, and then send the message back to your background service worker.
With chrome.system.display.getInfo() you can get the current screen width and height.

Thanks,
Stefan vd

Uladzimir Yankovich

unread,
Oct 7, 2022, 10:18:26 AM10/7/22
to Chromium Extensions, stefa...@gmail.com, nors...@gmail.com, Chethiya Abeysinghe, chromium-...@chromium.org, Chris Naegelin

Mohsin Khan

unread,
Oct 7, 2022, 11:08:17 AM10/7/22
to Chromium Extensions, Chethiya Abeysinghe
i also got the answer

Nathan Pierce

unread,
Oct 7, 2022, 3:48:11 PM10/7/22
to Chromium Extensions, pakista...@gmail.com, Chethiya Abeysinghe
await chrome.system.display.getInfo() is ppppperfect for me! Thanks!

Stefan Van Damme

unread,
Oct 8, 2022, 5:05:46 PM10/8/22
to Chromium Extensions, nors...@gmail.com, pakista...@gmail.com, Chethiya Abeysinghe
Great. You are welcome.

Thanks,
Stefan vd
Reply all
Reply to author
Forward
0 new messages