Skip to content

Instantly share code, notes, and snippets.

@TakuyaHarayama
Last active December 11, 2017 17:17
Show Gist options
  • Save TakuyaHarayama/74921cc0ca21da4f1926030cce7d278d to your computer and use it in GitHub Desktop.
Save TakuyaHarayama/74921cc0ca21da4f1926030cce7d278d to your computer and use it in GitHub Desktop.
(function(window, $) {
//'use strict';
var Device = function() {
var u = window.navigator.userAgent.toLowerCase();
return {
isTablet: (u.indexOf("windows") != -1 && u.indexOf("touch") != -1) || u.indexOf("ipad") != -1 || (u.indexOf("android") != -1 && u.indexOf("mobile") == -1) || (u.indexOf("firefox") != -1 && u.indexOf("tablet") != -1) || u.indexOf("kindle") != -1 || u.indexOf("silk") != -1 || u.indexOf("playbook") != -1,
isMobile: (u.indexOf("windows") != -1 && u.indexOf("phone") != -1) || u.indexOf("iphone") != -1 || u.indexOf("ipod") != -1 || (u.indexOf("android") != -1 && u.indexOf("mobile") != -1) || (u.indexOf("firefox") != -1 && u.indexOf("mobile") != -1) || u.indexOf("blackberry") != -1
};
};
var device = new Device();
/* UA振り分けでSPサイトを表示 */
if (device.isMobile) {} else if (device.isTablet) {} else {
var redirect = '../';
location.href = redirect;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment