首页 > 代码库 > 完美解决微信端设置title失败问题

完美解决微信端设置title失败问题

document.setTitle = function(t) {
document.title = t;
var i = document.createElement(‘iframe‘);
  i.src = http://www.mamicode.com/‘/favicon.ico‘;
  i.style.display = ‘none‘;
  i.onload = function() {
  setTimeout(function(){
    i.remove();
  }, 0)
  }
document.body.appendChild(i);
}

setTimeout(function(){
  document.setTitle(‘hello!’)
}, 1000)

 

完美解决微信端设置title失败问题