Javascript
1. Detect and redirect based on screen size
Below code will detect device’s screen size and if it’s less than 699 pixels, it will redirect it to your mobile enabled site (in this example m.yoursite.com).
Place the below code between <head> and </head> tags of your page. And replace “http://m.yoursite.com” to your own URL.
|
1 2 3 4 5 6 7 |
<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "http://m.yoursite.com";
}
//-->
</script> |
2. Detect and redirect if the device agent matches iPhone or iPod
Below code will specifically look out for iPhone and iPod devices, once matches, it will redirect them to your mobile enabled site (in this example m.yoursite.com). full details »
