Matt Sadev
Matt Sadev

Reputation: 123

Get The Static Screen Width of A Device Using Pure Javascript

I am returning image quality on my webpage based on the physical width of a device. This value should be static. The most reliable solution I know so far must be screen.width property.

However, in the current Firefox I am using, the value of screen.width is not static. When I switched to responsive design view (or ctrl + shift + m), then querying screen.width, the value corresponded to current viewport width, not the real physical width.

I noticed this when switching to the responsive design view, and reload the page, all images were blurred, having very bad quality.

So, is there some way I can get the static or real physical screen width of a device using pure Javascript? Maybe a tiny library?

Upvotes: 1

Views: 377

Answers (1)

Akshay G
Akshay G

Reputation: 2280

screen.availWidth and screen.availHeight will give you the actual available width and height

Upvotes: 2

Related Questions