util-13.微信公衆號相關(wechatUtil)


/**
 * ========================13.wechat公衆號相關 s========================
 */

/**
 * 含有輸入框的彈出面板fixed定位引發的ios事件錯亂問題
 */
document.addEventListener('focusout', function(e) {window.scrollTo()});

var wechatUtil = {
    /**
     * 設置頁面標題兼容ios
     * @param title //標題字符串
     */
    "setDocumentTitle" : function(title){
        var $body = $('body');
        document.title = title;
        var $iframe = $("<iframe style='display:none;' src='../resources/images/favicon.ico'></iframe>");
        $iframe.on('load',function() {
            setTimeout(function() {
                $iframe.off('load').remove();
            }, 0);
        }).appendTo($body);
    },
    "setDocumentTitleJS" : function(title){
        document.title = title;
        var iframe = document.createElement("iframe");
        iframe.id = "iframe";
        iframe.src = "../images/favicon.ico";
        iframe.style.cssText = "display:none";
        iframe.addEventListener("load",function(){
            document.body.appendChild(iframe);
            setTimeout(function() {
                iframe.removeEventListener('load');
                iframe.parentNode().removeChild(document.getElementById("iframe"));
            }, 0);
        })
    }
};

/**
 * ========================13.wechat公衆號相關 e========================
 */

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章