Created
December 17, 2014 03:36
-
-
Save veryblue/3831280ff84314aa6bfd to your computer and use it in GitHub Desktop.
js スマホ版切替ボタンの表示
This file contains 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
var query = location.search; | |
var cookieStr = document.cookie; | |
var code = '<div><a href="sp/?viewmode=sp">スマートフォン版に切り替え</a></div>'; | |
if (query.indexOf("viewmode=pc")!=-1){ | |
document.write(code); | |
} else if (cookieStr.indexOf("viewmode=pc")!=-1){ | |
document.write(code); | |
} else if ((navigator.userAgent.indexOf('iPhone') > 0 | |
&& navigator.userAgent.indexOf('iPad') == -1) | |
|| navigator.userAgent.indexOf('iPod') > 0 | |
|| navigator.userAgent.indexOf('Android') > 0) { | |
document.write(code); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment