美文网首页
微信修改title

微信修改title

作者: power__c081 | 来源:发表于2017-03-07 22:23 被阅读0次

最近在开发微信公众号,遇到了一个问题,就是微信title问题.

document.title="";

这个方法是改变不了微信title的;

这里介绍一种方法:

function setTitle(t) {

document.title = t;

var iframe = document.createElement('iframe')

iframe.style.visibility = 'hidden'

// 替换成站标favicon路径或者任意存在的较小的图片即可

iframe.setAttribute('src', 'pic.ico')    //pic.ico为小图片url

var iframeCallback = function () {

setTimeout(function () {

iframe.removeEventListener('load', iframeCallback)

document.body.removeChild(iframe)

}, 0)}

iframe.addEventListener('load', iframeCallback)

document.body.appendChild(iframe)

}

只需要传入参数t(PS:想起名的title)即可改变微信上面的title

相关文章

网友评论

      本文标题:微信修改title

      本文链接:https://www.haomeiwen.com/subject/uajvgttx.html