1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 5.00 out of 5)

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.

<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>

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

Tip: Click on images to make them larger. If you find anything wrong on this page or need further assistance please comment below or contact me. 🙂

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

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

Subscribe To My YouTube Channel:

Please like, share and subscribe.

Advanced Programming Made Easy

I hope you enjoyed the article. If I was able to help you please consider a tip for the content.

One Time Tip

more tips

Reoccuring Tips

Tips

Cool People Share:
MOBILE FRIENDLY WEBSITES

Leave a Reply

Your email address will not be published. Required fields are marked *

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