Created
January 28, 2012 19:19
-
-
Save coolniikou/1695484 to your computer and use it in GitHub Desktop.
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 src="js/jquery_1.6.4.min.js" type="text/javascript"></script> | |
| <script src="js/jquery.cookie.js" type="text/javascript"></script> | |
| function detect_device() { | |
| var user_agent = [ | |
| 'iPhone', | |
| 'iPad', | |
| 'iPod', | |
| 'Android' | |
| ]; | |
| var pattern = new RegExp(user_agent.join('|^'), 'i'); | |
| return pattern.test(navigator.userAgent); | |
| } | |
| function smartphone_site() { | |
| var message = confirm("ã¹ãã¼ããã©ã³ãµã¤ãã表示ãã¾ããï¼"); | |
| if(message == true) { | |
| $.cookie('detect_device_mode', 'smartphone', {path: '/'}); | |
| location.href = "./smartphone/"; | |
| } else { | |
| $.cookie('detect_device_mode', 'pc', {path: '/'}); | |
| } | |
| } | |
| if(detect_device() && $.cookie('detect_device_mode') == null) { | |
| smartphone_site(); | |
| } else if($.cookie('detect_device_mode') == 'smartphone'); { | |
| location.href = "./smartphone/"; | |
| } | |
| <a onclick="smartphone_site" href="javascript:void(0)">change to smartphone_site</a> |
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
| #mod_rewite enabled on | |
| RewriteEngine On | |
| RewriteCond %{HTTP_USER_AGENT}(iPhone|iPod) | |
| RewriteCond %{QUERY_STRING} !mode=pc | |
| RewriteRule ^$ /smartphone/ [R] | |
| RewriteCond %{HTTP_USER_AGENT} iPad | |
| RewriteCond %{QUERY_STRING} !mode=pc | |
| RewriteRule ^$ /smartphone/ [R] | |
| RewriteCond %{HTTP_USER_AGENT} Android | |
| RewriteCond %{QUERY_STRING} !mode=pc | |
| RewriteRule ^$ /smartphone/ [R] | |
| RewriteCond %{QUERY_STRING} !mode=pc |
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
| function detact_device() { | |
| var user_agent = [ | |
| 'iPhone', | |
| 'iPad', | |
| 'iPod', | |
| 'Android' | |
| ]; | |
| var pattern = new RegExp(user_agent.join('|^'), 'i'); | |
| return pattern.test(navigator.userAgent); | |
| } | |
| if(detect_device()) { | |
| location.href = "/smartphone/" | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment