首页 > 代码库 > jQurey浏览器页卡切换 用于实时接口的长轮询

jQurey浏览器页卡切换 用于实时接口的长轮询

加页卡切换,

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Document</title>    <script type="text/javascript" src="http://mat1.gtimg.com/www/js/jquery/jquery-1.11.1.min.js"></script>    <script>/***   切换浏览器tab,判断当前tab是否活跃***/    (function(g, h, $, b) {        var e, i, f = onfocusin in h && hasFocus in h ? focusin focusout : focus blur,            d = [‘‘, moz, ms, o, webkit],            c = $.support,            a = $.event;        while ((i = e = d.pop()) != b) {            i = (e ? e + H : h) + idden;            if (c.pageVisibility = typeof h[i] == boolean) {                f = e + visibilitychange;                break            }        }        $(/blur$/.test(f) ? g : h).bind(f,            function(m) {                var l = m.type,                    j = m.originalEvent,                    k = j.toElement;                if (!/^focus./.test(l) || (k == b && j.fromElement == b && j.relatedTarget == b)) {                    a.trigger((i && h[i] || /^(?:blur|focusout)$/.test(l) ? hide : show) + .visibility)                }            })    }(this, document, jQuery));    var o={}    o.$tabFlag = true;     /**  切换页卡 **/      var changeTab=function() {        //var _this = this;        //var o = this.options;        console.log(333)        $(document).bind({            show.visibility: function() { // 当前活跃                o.$tabFlag = true;                console.log(222)            },            hide.visibility: function() { // 失去当前状态                o.$tabFlag = false;                console.log(11111)            }        });    }        changeTab();    </script></head><body>    </body></html>  

 

jQurey浏览器页卡切换 用于实时接口的长轮询