Reputation: 31365
When I log window.screenX
on my desktop Chrome, I see the value 1920
When I do the same on my phone and iPad both on Safari and Mobile I either see 0
or some really weird values.
From MDN Link:
QUESTION
Isn't that supposed to work on both desktop and mobile, devices and browsers?
Upvotes: 2
Views: 1507
Reputation: 1512
What information are you actually trying to return? From your MDN link:
Returns:
A number equal to the number of CSS pixels from the left edge of the browser viewport to the left edge of the screen.
Do you have your browser in a windowed mode on your mobile devices? Because in a full screen mode, like most mobile device browsers remain in, it should always return 0
because there are no pixels between the left hand side of the device's screen and the start of the browser window.
Are you actually trying to measure the space between the left side of the screen and the start of the browser viewport, or are you really trying to get the horizontal resolution of the entire screen? If it is the latter, what you are looking for may be the window.screen.width
property. The documentation for that property can be found here on MDN.
Upvotes: 2