Last active
August 29, 2015 14:16
-
-
Save PhilReinking/d512c6f82fbf9dfb34fe to your computer and use it in GitHub Desktop.
redirect to mobile site script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mobile Detect and redirect | |
var isMobileSite = document.location.search.match('mobile=1'); | |
var mobileUrl = 'http://www.yoururl.com/'; | |
if( !isMobileSite && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) | |
{ | |
window.top.location = mobileUrl + '?mobile=1'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment