Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7040437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:55:06+00:00 2026-05-28T01:55:06+00:00

I have a website that, when accessed by a mobile browser, to redirect to

  • 0

I have a website that, when accessed by a mobile browser, to redirect to a different page.

I have been having trouble coming up with a way that reliably detects mobile devices. Currently, I Javascript code like this:

if (document.documentElement.clientWidth < 680 || 
    document.documentElement.clientHeight < 450) 
  location.href = "handheld.aspx";

that redirects if the broswer size is smaller than what is supported on the desktop version. The problem with this is that some mobile browsers start zoomed way out and have the similar browser dimensions as desktop devices.

I’ve researched this some, and I’ve mainly found solutions that involve sniffing the user agent sting and checking it against a bunch of strings in existing mobile devices. If possible, I’d like to avoid that route because it seems extremely messy and will break in the future when new devices come out.

Is there a less kludgy way to detect mobile browsers, or at least a more reliable way to detect screen size?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:55:06+00:00Added an answer on May 28, 2026 at 1:55 am

    You have to decide which aspect of a mobile browser you are most trying to detect. Are you trying to detect the screen size and redirect to a site design that fits on a smaller screen. If so, you can use window.screen (doc here).

    If you’re trying to detect specific capabilities or lack of capabilities in mobile browsers, then you should use feature detection to find out whether the specified features are there or not there. This is way better than detecting browser user agents.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have this website that will be accessed via an SSL connection (
I have a website that is deployed between 3 different environments - Dev, Stage,
I have an asp.net website that has been running well in IIS 6.0. I
Given a website site has different web pages that can only be accessed by
Here is the situation, i have a website that can be accessed from multiple
I have a website that would ideally be accessed by users who have downloaded
I have a website that plays mp3s in a flash player. If a user
I have a website that I've just uploaded onto the Internet. When I browse
We have a website that uses #include file command to roll info into some
I have a website that is perfectely centered aligned. The CSS code works fine.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.