美文网首页
ios微信使用 document.title 动态修改标题无效

ios微信使用 document.title 动态修改标题无效

作者: sherlock221b | 来源:发表于2017-08-31 17:42 被阅读153次

    在ios微信中 开发spa单页面应用 在路由切换的钩子函数中 写入document.title =xx ,来尝试修改页面标题 发下无效。

    最后网上给出的方案 加载空iframe 来去做.
    vue 代码:

      let iframe = document.createElement('iframe')
      iframe.style.display = 'none'
      iframe.src = src
      document.body.appendChild(iframe)
      iframe.addEventListener('load', function() {
        setTimeout(function() {
          iframe.remove()
        }, 0)
      })
    }
    

    jq的

    document.title = "title";
    var $body = $('body');
    var $iframe = $('<iframe src="/favicon.ico"></iframe>');
    $iframe.on('load',function() {
      setTimeout(function() {
          $iframe.off('load').remove();
      }, 0);
    }).appendTo($body);
    

    相关文章

      网友评论

          本文标题:ios微信使用 document.title 动态修改标题无效

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