Skip to content

Redirect to Mobile Version of Website

December 22, 2013

If you have created a mobile version of your existing website. And now you want to redirect users with mobile devices to that version of website. Below is the javascript code to change the location to the page specifically created for mobile users.

1. <script type="text/javascript">

2. <!-- 

3. if (screen.width <= 699) {

4. document.location = "mobile_site.html"; }

5. //-->

6.</script>

In the line number 3 of above code

(screen.width <= 699)

screen.width represents total width of the user screen, in pixels.

In line number 4,

document.location = "mobile_site.html";

"mobile_site.html"

is the location of your mobile version of the website.

Happy mobile programming……

Advertisements

From → Uncategorized

Leave a Comment

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

%d bloggers like this: