How redirect mobile users to different url?

偶尔善良 提交于 2019-12-11 15:56:41

问题


I used the following script to redirect mobile users to a mobile site:

<script type="text/javascript">
    if (screen.width < 800) {
        var ref = document.referrer;
        var urls = new Array("http://www.ilsanlorenzo.net","http://www.ilsanlorenzo.net/mobsite");
        var n = ref.match(urls[0]);
        var m = ref.match(urls[1]);
        if ((m!==null) || (n!==null)) {
            stop;
        } else if (ref=='') {
            var r = confirm("Small Display is Detected.\nClick \"OK\" for MOBILE SITE.");
            if (r==true) {
                window.location = "http://www.ilsanlorenzo.net/mobsite";
            } else {
                stop;
            }
        } else {
            window.location = "http://www.ilsanlorenzo.net/mobsite";
        }
    }
</script>

I would like to know if anyone knows a script to redirect mobile users to a mobile site version and tablet and desktop users to a web site version. Does anyone know a solution?

Thanks for your time!

来源:https://stackoverflow.com/questions/16884056/how-redirect-mobile-users-to-different-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!