首页 > Web开发 > 详细

js修改页面标题 title

时间:2019-10-18 18:47:50      阅读:145      评论:0      收藏:0      [点我收藏+]

如果对你有帮助的话麻烦点个【推荐】~最好还可以follow一下我的GitHub~感谢观看!

    /* *
     *添加首页description元数据meta标签
     *创建一个meta元素,sName为该meta元素的name值, sDescription为该meta元素的description值。
     */
    window.addEventListener('load', function () {
        var docTitle = document.title;
        document.title = docTitle.replace(" - 博客园","") + ' | Eric\'Blog'
        var dMeta = document.createElement('meta');
        var sName = 'keywords';
        var sDescription = "梦逸灵箭";
        dMeta.setAttribute('name', sName);
        dMeta.setAttribute('content', sDescription);
        document.head.appendChild(dMeta);
    
        var dMeta1 = document.createElement('meta');
        var sName1 = 'description';
        var sDescription1 = "梦逸灵箭,博客,代码";
        dMeta1.setAttribute('name', sName1);
        dMeta1.setAttribute('content', sDescription1);
        document.head.appendChild(dMeta1);
    },false);

js修改页面标题 title

原文:https://www.cnblogs.com/mengyilingjian/p/11699659.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!