//需要jQuery、zepto版
function weixinTitle(){
var $body = $(\'body\');
document.title = \'title\';
// hack在微信等webview中无法修改document.title的情况
var $iframe = $(\'<iframe src="/favicon.ico"></iframe>\');
$iframe.on(\'load\',function() {
setTimeout(function() {
$iframe.off(\'load\').remove();
}, 0);
}).appendTo($body);
}
//需要js原生版本
function weixinTitle(title){
var $body = document.body;
document.title = title;
// hack在微信等webview中无法修改document.title的情况
var $iframe = createDom(\'<iframe src="/favicon.ico"></iframe>\');
$iframe.addEventListener(\'load\', load);
$body.appendChild($iframe);
function load(){
setTimeout(function() {
$iframe.removeEventListener(\'load\', load);
$body.removeChild($iframe);
}, 0);
}
function createDom(htmlStr){
var tmp = document.createElement(\'div\');
tmp.innerHTML = htmlStr;
var children = tmp.childNodes;
for (var i = 0; i < children.length; i++) {
if (children[i].nodeType ===1 ) {
return children[i];
}
}
return;
}
}