CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2017

    Screen.width property discrepancy.

    I'm trying following simple JavaScript code:

    On my Samsung A5(2017) smartphone. The specs for my device screen is `1080 x 1920` pixels while the alert reports me only `360` as `screen.width` value. My question is why there is such discrepancy between the vale of specs and the valeu returned by the code?
    Last edited by PeejAvery; June 4th, 2018 at 10:19 PM. Reason: Changed prefix

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002

    Re: Screen.width property discrepancy.

    Cell phones use variations of images depending on the resolution. You're device is registered as 360 @3x. You'll need to calculate the actual pixels by using screen.width * window.devicePixelRatio.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width