實(shí)現(xiàn)思路蜕衡,在網(wǎng)頁加載完成之后手動(dòng)模擬一次網(wǎng)絡(luò)請(qǐng)求壤短,設(shè)置標(biāo)題
實(shí)現(xiàn)思路,在網(wǎng)頁加載完成之后手動(dòng)模擬一次網(wǎng)絡(luò)請(qǐng)求慨仿,設(shè)置標(biāo)題
使用Jquery久脯、zepto
/**
* 修改頁面標(biāo)題
* @param {[type]} title [description]
*/
utils.setTitle=function(title){
var $body = $('body');
document.title = title;
var $iframe = $('<iframe style="display:none" src="https://m.putao.cn/PutaoLife/resources/images/favicon.png"></iframe>');
$iframe.on('load',function() {
setTimeout(function() {
$iframe.off('load').remove();
}, 0);
}).appendTo($body);
};
使用原生JS
utils.setTitle=function(title){
document.title = title;
var mobile = navigator.userAgent.toLowerCase();
if (/iphone|ipad|ipod/.test(mobile)) {
var iframe = document.createElement('iframe');
iframe.style.visibility = 'hidden';
iframe.setAttribute('src', 'loading.png');
var iframeCallback = function() {
setTimeout(function() {
iframe.removeEventListener('load', iframeCallback);
document.body.removeChild(iframe);
}, 0);
};
}
};