当前位置:首页 > Web开发 > 正文

// change its href to the given link. if ($favicon !== null

2024-03-31 Web开发

const changeFavicon = link => { let $favicon = document.querySelector(‘link[rel="icon"]‘); // If a <link> 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; // 动态改削网站标题

js 设置网页图标和标题

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/30294.html