sou
6/22/2017 - 12:11 AM

デバイス振り分け PC・SPで振分け

デバイス振り分け PC・SPで振分け

(function() {
    var ua = navigator.userAgent.toUpperCase();
    var url = document.location.pathname;
    var spDir = 'index_sp.html';

    (ua.indexOf('IPHONE') != -1 || (ua.indexOf('ANDROID') != -1 && ua.indexOf('MOBILE') != -1)) ?
    isSP():
        isPC();

    function isSP() {
        if (url.match(spDir)) {
            return false;
        } else {
            location.href = spDir;
        }
    }

    function isPC() {
        if (!url.match(spDir)) {
            return false;
        } else {
            location.href = '/';
        }
    }
}());