device check
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
function iOS_hasRetinaDisplay() | |
{ | |
return window.devicePixelRatio > 1; | |
} | |
//UAでデバイスのチェック | |
function iOS_initPage() | |
{ | |
if(navigator.standalone) iOS_createWebappLinks(); | |
// iOS class | |
var ua = navigator.userAgent; | |
if(iOS_isiOSdevice()) | |
{ | |
var html = document.documentElement; | |
// set the iOS class on <html> | |
var classes = html.className.split(" "); | |
if(classes.indexOf("iOS") == -1) classes.push("iOS"); | |
if(iOS_hasRetinaDisplay() && classes.indexOf("retina") == -1) classes.push("retina"); | |
html.className = classes.join(" "); | |
// Device | |
if(ua.indexOf("iPhone") > -1) html.setAttribute("device", "iPhone"); | |
else if(ua.indexOf("iPod") > -1) html.setAttribute("device", "iPod"); | |
else if(ua.indexOf("iPad") > -1) html.setAttribute("device", "iPad"); | |
// Device Family | |
if(ua.indexOf("iPhone") > -1 || ua.indexOf("iPod") > -1) html.setAttribute("deviceFamily", "iPhone_iPod"); | |
else if(ua.indexOf("iPad") > -1) html.setAttribute("deviceFamily", "iPad"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment