zoukankan      html  css  js  c++  java
  • 判断手机设备并跳转

    百度的uaredirect.js

    用法:

    <script src="http://siteapp.baidu.com/static/webappservice/uaredirect.js" type="text/javascript"></script>
    <script type="text/javascript">uaredirect("http://www.xxx.cn/xx/wap/index.html手机版地址");</script>
    function uaredirect(f) {
        try {
            if (document.getElementById("bdmark") != null) {
                return
            }
            var b = false;
            if (arguments[1]) {
                var e = window.location.host;
                var a = window.location.href;
                if (isSubdomain(arguments[1], e) == 1) {
                    f = f + "/#m/" + a;
                    b = true
                } else {
                    if (isSubdomain(arguments[1], e) == 2) {
                        f = f + "/#m/" + a;
                        b = true
                    } else {
                        f = a;
                        b = false
                    }
                }
            } else {
                b = true
            }
            if (b) {
                var c = window.location.hash;
                if (!c.match("fromapp")) {
                    if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i))) {
                        location.replace(f)
                    }
                }
            }
        } catch(d) {
    
    }
    }
    function isSubdomain(c, d) {
        this.getdomain = function(f) {
            var e = f.indexOf("://");
            if (e > 0) {
                var h = f.substr(e + 3)
            } else {
                var h = f
            }
            var g = /^www./;
            if (g.test(h)) {
                h = h.substr(4)
            }
            return h
        };
        if (c == d) {
            return 1
        } else {
            var c = this.getdomain(c);
            var b = this.getdomain(d);
            if (c == b) {
                return 1
            } else {
                c = c.replace(".", "\.");
                var a = new RegExp("\." + c + "$");
                if (b.match(a)) {
                    return 2
                } else {
                    return 0
                }
            }
        }
    }
  • 相关阅读:
    第一个SpringBoot
    windows 安装 mysql 及部分命令
    别让猴子跳回背上
    windows环境下基于Anaconda安装Tensorflow
    spark
    ubuntu环境下安装chrome
    前言
    模型压缩(4)
    模型压缩(3)
    模型压缩(2)
  • 原文地址:https://www.cnblogs.com/lichihua/p/10535636.html
Copyright © 2011-2022 走看看