Simple way to redirect user if Mobile

Javascript can detect screen size and redirect users if they are using mobile. I’ve found that checking the screen size and redirecting users based on that can cover 99% of the use cases rather than injecting some complicated browser detection javascript libraries.

The screen width of IPAD is 768px and screen width of a bigger mobile is 500px. So it would be safe to say that you anyone browsing the site using mobile phone would have a resolution lesser than 700px.

A simple script like that will work

if (screen.width <= 700) {
  window.location = "http://your-mobile-site";
Like it.? Share it:

Comments are closed.