Mobile Website Redirect Script

Having recently setup a mobile website to accompany our main corporate site I wanted to find a way of automatically redirecting all mobile traffic to the new site.

To do this I added the scripts below shown below.

<script type="text/javascript"> <!-- if (screen.width <= 699) { document.location = "mobile.html"; } //--> </script>

If you wanted to specifically target Iphone or Ipads then you could use the following

<script language=javascript> <!-- if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {    location.replace("http://url-to-send-them/iphone.html"); } --> </script>

Advertisement

About Martin Meddle

I am an independent freelance IT Consultant who works with individuals, small businesses and large companies. I can provide fast solutions to many of your business problems. This may involve the development of a complete software system, or simply technical support. View all posts by Martin Meddle

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.