标签:change cto const == end 图标 exists 网页 sts
const changeFavicon = link => { let $favicon = document.querySelector(‘link[rel="icon"]‘); // If a <link rel="icon"> element already exists, // change its href to the given link. if ($favicon !== null) { $favicon.href = link; // Otherwise, create a new element and append it to <head>. } else { $favicon = document.createElement("link"); $favicon.rel = "icon"; $favicon.href = link; document.head.appendChild($favicon); } }; let icon = ‘‘; // 图片地址 changeFavicon(icon); // 动态修改网站图标 let title = ‘‘; // 网站标题 document.title = title; // 动态修改网站标题
标签:change cto const == end 图标 exists 网页 sts
原文地址:https://www.cnblogs.com/mary-123/p/12285008.html