通常情況下,我們使用document.title=”標題名”來動態的修改標題,但是此方法在微信iOS端並沒有用,查了不少資料,終於解決這個問題啦。現在把代碼分享出來給大家
function wxSetTitle(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);
};
iframe.addEventListener('load', iframeCallback);
document.body.appendChild(iframe);
}
}
直接調用此方法就可以啦