Results 1 to 8 of 8

Thread: Screen Size Redirect Script

  1. #1
    Join Date
    Jan 2006
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Screen Size Redirect Script

    Okay the one I found here: http://www.dynamicdrive.com/dynamicindex9/info3.htm works great, the only thing im trying to do though is set it up so

    users with a screen resolution larger than 800x600 go to the full size site
    and every one else smaller than 800x600 will go to the mobile or small scaled down site.

    anyone know how I might be able to modify this java script to fit what im looking for?

    Thanks!!
    -Kevin

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It shouldn't be to hard, I bet you could do it if you just took a bit of time looking over the code. However, before you, I or anyone does it, I think you should decide where the 800x600 folks will be sent:

    Quote Originally Posted by Neebski
    users with a screen resolution larger than 800x600 go to the full size site
    and every one else smaller than 800x600 will go to the mobile or small scaled down site
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Sep 2004
    Location
    Indonesia
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    It shouldn't be to hard, I bet you could do it if you just took a bit of time looking over the code. However, before you, I or anyone does it, I think you should decide where the 800x600 folks will be sent:
    LOL

    @Neebski: Try this...

    Code:
    if (screen.width>800||screen.height>600) //larger than 800x600
    window.location.replace("http://www.mysite.com/fullsize")
    
    else if (screen.width<640||screen.height<480) //if smaller than 800x600
    window.location.replace("http://www.mysite.com/reducedsize")
    
    else if (screen.width==800||screen.height==600) //if 800x600 ;) 
    window.location.replace("http://www.mysite.com/normalsize")

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yuck. Sending users to different pages based on screen size is a very bad idea. You can never anticipate every possible screen size and geometry.

    Sending users to a different page based on whether they're using a mobile device or not, which is what the OP appeared to be intending, is a much better one. However, 800x600 is rather too large to be a boundary, I think.
    Code:
    if((screen.width + screen.height) < 800) window.location.replace("http://www.example.com/mobile/");
    Also, put that on your main page, so that non-Javascript browsers won't be left with an empty page.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jan 2006
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    so maybe, smaller than 500x yah??

    I just threw out 800x600 just for an example

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yes. My code will work reasonably well.
    Ideally, this should be done server-side: WAP-enabled devices use a distinctive Accept header including several WAP- and WML-related filetypes.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jan 2006
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    right... I dont really think ill get that running soon :P

    im just trying to figgure out this stuff haha

  8. #8
    Join Date
    Jun 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hello everyone,
    can I put more than 4 criterias into the code. Means can I specify two more over 4 totalling 6 screen size criteria by adding following:

    else if (screen.width==640||screen.height==480) //if 640x480
    window.location.replace("http://www.microsoft.com")

    with different height width. Please reply.

    Thank you.

Bookmarks

Posting Permissions

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