js判断终端&动态引进js库

LZQQQ 发布于 2016/01/28 11:15
阅读 266
收藏 0

直接上代码--------

<script type="text/javascript">

     //终端判断
     (function() {
        var os = function() {
                var ua = navigator.userAgent,
                isWindowsPhone = /(?:Windows Phone)/.test(ua),
                isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone,
                isAndroid = /(?:Android)/.test(ua),
                isFireFox = /(?:Firefox)/.test(ua),
                isChrome = /(?:Chrome|CriOS)/.test(ua),
                isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)),
                isIPhone = /(?:iPhone)/.test(ua) && !isTablet,
                isPc = !isIPhone && !isAndroid && !isSymbian && !isTablet;
                return {
                        isWindowsPhone: isWindowsPhone,
                        isTablet: isTablet,
                        isIPhone: isIPhone,
                        isAndroid: isAndroid,
                        isPc: isPc
                };
        } ();
        if (os.isPc) {
                document.write("<script src='js/jquery-1.8.0.min.js'><\/script>");
              // s1.src = 'js/jquery-1.8.0.min.js';
        } else{
            document.write("<script src='js/zepto.min.js'><\/script>");
        }
        })();
            window.onload = function(){
            $("#showTooltips").on('click',function(){
                alert($(this))
            })
            }
     </script>
加载中
返回顶部
顶部