js修改页面标题 title


如果对你有帮助的话麻烦点个【推荐】最好还可以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);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM