How to redirect to mobile site

How to redirect to mobile site

Redirect to mobile site because its easy! So you have your website set up and a mobile friendly site but you still need to redirect to mobile site. What we can do is use java script to figure out what size screen the user is using. If they surfer is using a smaller browser like that on a tablet or a cell phone we may want to redirect that person to out mobile site. I have included a script here that you should put in your head tags on your website. Now you can use this script to also point anyone with a smaller browser to any site that you wish but we will assume that you just want to direct them to another part of your website. Here is what the script looks like. In this script we are redirecting everyone that has a screen size 699 pixels or smaller to another part of our website. I also included an iPhone redirect script to tell iPhones where to go and it does not matter what their screen size is, lol.

[php]
<script type="text/javascript">
<!–
if (screen.width <= 699) {
document.location = "folder/index.php";
}
//–>
</script>
<script language=javascript>
<!–
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("https://www.a1websitepro.com/index.php");
}
–>
</script>
[/php]

Redirect to mobile site is easy using this code all you have to do is replace the destinations.
redirect to mobile site

If you need lessons on how to edit php please visit our lessons page.

Only cool people share!

How to redirect to mobile site was last modified: May 13th, 2015 by Maximus Mccullough
MOBILE FRIENDLY WEBSITES

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.