Redirect users with mobile devices

English: Sharp Smartphone Android IS03 日本語: シャ...

There are a couple of different methods to re-direct users using mobile devices such as iPhones and Android phones to your mobile website.  One of the easiest way though is to add a simple bit of javascript to to the <HEAD> section of your web page.

This snippet of code will redirect the user to a different page based on their screen size.

<script type="text/javascript">
   if (screen.width<699) {
      window.location="http://my.mobilesite.com";
   }
</script>

In this example a user browsing to your website with a screen size of less that 699 pixels wide will be redirected to the website http://my.mobilesite.com (you can change this to your mobile website).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s