Category: Tips

Redirect Mobile Devices

Posted by & filed under Tips.

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.

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 »