Last active
August 29, 2015 14:17
-
-
Save sanusart/b4875eb264e46a0e789b to your computer and use it in GitHub Desktop.
Redirect to mobile #mobile #javascript
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
| <script type="text/javascript"> | |
| if ( window.sessionStorage.getItem('mob') !== 'no' ) { | |
| if ((navigator.userAgent.match(/iPhone|Android|iPod|Opera Mobi|Opera Mini|BlackBerry|Nokia|SymbianOS|Windows CE|BenQ/i))) { | |
| window.sessionStorage.setItem('mob','no'); | |
| var url = window.location.href; | |
| var paramPos = url.indexOf("?"); | |
| location.replace("http://domain.com/m-site/" + ( paramPos != -1 ? "?" + url.substr(paramPos + 1) : "" )); | |
| } | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment