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