Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IE detects wrong screen resolution. Why?!?

    I have this script:

    Code:
    <SCRIPT language="JavaScript">
    <!--
    // small
    if ((screen.width>=1024) && (screen.width<1280))
    {
     window.location="0_framside/1_small/849x507.html";
    }
    
    // medium
    else if ((screen.width>=1280) && (screen.width<1400))
    {
     window.location="0_framside/2_medium/1105x507.html";
    }
    
    // large
    else if ((screen.width>=1400) && (screen.width<1600))
    {
     window.location="0_framside/3_large/1225x639.html";
    }
    
    // xlarge
    else if ((screen.width>=1600) && (screen.width<1920))
    {
     window.location="0_framside/4_xlarge/1425x789.html";
    }
    
    // manual
    else
    {
      window.location="resolution.html";
    }
    //-->
    </SCRIPT>
    See the page in action here: http://www.kollalfa.com/temp_LesForMeg/index2.html

    The problem?

    On a computer with 1280x1024 resolution, IE detects it to be 1024 (thus sending the user to the wrong page). It works perfectly in all other browsers (that I have tried).

    Any ideas? Thanks in advance!

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,243
    Thanks
    203
    Thanked 2,555 Times in 2,533 Posts
    http://www.javascriptkit.com/howto/newtech3.shtml

    Maybe use window.screen.width rather than screen.width.


    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
    Last edited by Philip M; 04-01-2010 at 08:34 PM.

  • #3
    Banned
    Join Date
    Nov 2008
    Location
    not found
    Posts
    284
    Thanks
    0
    Thanked 53 Times in 51 Posts
    So obviously the first thing you did was to insert at the start of the code
    alert( screen.width );, and the result was?

  • #4
    Regular Coder
    Join Date
    Feb 2009
    Location
    NJ, USA
    Posts
    476
    Thanks
    2
    Thanked 70 Times in 69 Posts
    Quote Originally Posted by Philip M View Post
    Maybe use window.screen.width rather than screen.width.
    Philip, window.screen == screen...

    Every browser object is a child of the Global JavaScript object, i.e. window.

    -------------------------------------------

    kollalfa, the screen.height and screen.width properties can vary based on the browser's zoom level. This may be your problem.

    For instance, my screen width is 1280. Firefox reports that number on screen.width with no zoom. If I zoom in once (View -> Zoom -> Zoom In), Firefox reports screen.width to be 1152. Same goes for Internet Explorer. Zooming in once takes screen.width from 1280 to 1229. Zooming in 5 times takes the value to 1024.

    Try resetting your zoom in your browsers ("View" -> "Zoom" -> "Reset" on Firefox, "View" -> "Zoom" -> "100%" on IE), and see if the numbers are reported correctly from then on. This will all depend on the client's settings too of course.

    And try randomuser773's suggestion of alerting the screen.width while you are trying to figure out this issue. Will save you a lot of time, rather than continually experiencing redirects.

    Hope that helps.

    -Greg

  • #5
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Superthanks, people!

    I will try your suggestions shortly.


  •  

    Posting Permissions

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