Pages

Friday, December 14, 2012

Mobile Redirect Code using Javascript For ANY Mobile Device

Views

Javascript Mobile Device Detection

Here is the simplest Javascript Mobile Redirect Code we’ve found. It work regardless of the device, as long as it’s screen size is less that what you specify in the script. In this example and device that has a screen smaller than 700 pixels will get your mobile website redirect. The idea is that mobile devices will not have a screen width wider than a certain pixel size (e.g. 700 or 800). Users with a screen width less than what you specify will be redirected to the mobile site. Here’s an example of the Javascript you would want to insert into each of your pages:
<script type=”text/javascript”>
<!–
if (screen.width <= 700) {
window.location = “https://yourweburl.com/mobile/”;
}
//–>
</script>

Having a mobile version of your website is a great way to make sure that visitors using a mobile device are able to properly view your site on their device. Some tools for creating mobile versions of websites have built-in options for redirecting visitors to the mobile versions. If not, you will want to redirect mobile visitors to the right version.

0 comments:

Post a Comment

 

Web Design Company karimnagar, Web Designing warangal, Logo Design Company nizamabad, Indian Website Design Company, maddysoft.co.in