让网站访客来源根据设备、语言判断访问不同网站。

<script type="text/javascript">
        window.onload = function() {
            if (window.location.href.indexOf('#') > -1) {
                return true;
            }
            var browserLanguage = (navigator.language || navigator.browserLanguage).toLowerCase();
            var userAgent = navigator.userAgent.toLowerCase();
            var url;
            var tip;
            var android = userAgent.indexOf('android') > -1;
            var iphone = userAgent.indexOf('iphone') > -1;
            var ipad = userAgent.indexOf('ipad') > -1;
            var ipod = userAgent.indexOf('ipod') > -1;
            var windows_phone = userAgent.indexOf('windows phone') > -1;
            var blackberry = userAgent.indexOf('blackberry') > -1;
            var symbia = userAgent.indexOf('symbia') > -1;
            var nokiabrower = userAgent.indexOf('nokiabrower') > -1;
            if (browserLanguage.indexOf('zh') > -1) {
                url = "http://www.网站.com/cn/";
                tip = "系统检测到您目前正在使用移动设备,建议您访问我们的移动版平台。";
            }
            else if (browserLanguage.indexOf('en') > -1) {
                url = "http://www.网站.com/en/";
                tip = "You are using mobile device, please visit our mobile platform.";
            }
            else if (browserLanguage.indexOf('fr') > -1) {
                url = "http://www.网站.com/fr/";
                tip = "Vous êtes en train d'utiliser l'appareil mobile, veuillez visiter notre plate-forme mobile.";
            }
            else {
                url = "http://www.网站.com/";
                tip = "You are using mobile device, please visit our mobile platform.";
            }
            if (android || iphone || ipad || ipod || windows_phone || blackberry || symbia || nokiabrower) {
                if (confirm(tip)) {
                    location.href = "http://m.网站.com";
                }
                else {
                    location.href = url;
                }
            }
            else {
                location.href = url;
            }
        }
       
    </script>

© 版权声明
THE END
請多多支持
点赞0
相关推荐
评论 抢沙发

    暂无评论内容