问题1:我现在找到的解决办法是
xxx.setDocumentTitle = function(title) {
document.title = title;
if (/ip(hone|od|ad)/i.test(navigator.userAgent)) {
var i = document.createElement('iframe');
i.src = '/favicon.ico';
i.style.display = 'none';
i.onload = function() {
setTimeout(function(){
i.remove();
}, 9)
}
document.body.appendChild(i);
}
}
这种方法我看不懂,求解释
问题2:为什么会出现这种情况?安卓端的微信浏览器可以用dom修改title,同样代码在ios端为啥没效果?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
直接change函数中
document.title = "xxx"赋值,你找的代码
/ip(hone|od|ad)/i.test(navigator.userAgent)判断是ios设备(正则判断navigator.userAgent)至于为什么创建一个iframe, 去改, 坐等神评.webview中包括微信的浏览器IOS设备是无法通过document.title来更改标题的
给你分享一段代码吧
核心思想是内嵌一个iframe去发起一个请求来触发IOS设备中更新title
在微信
6.5.3版本后用iframe的方式就不好使了。所以在一些SPA中,使用框架的路由用这种方式不起作用了。
我是用
location.href来进行页面的强刷,路由还是定义好路由的规则,但是通过location.href去接管页面的跳转。好使。3.23日更新
在微信
6.5.5版本iframe的方式又好使了。