dポイントプレゼントキャンペーン実施中!

Webサイトを表示時にタイトルの横に表示されるアイコンを変更したい。
Javascriptで変更を行ないたいのですが、指定の仕方がわかりません。

下記のHTMLタグで指定できる奴です。
<link rel="shortcut icon" href="favicon.ico" type="image/vnd.microsoft.icon">

よろしくお願い致します。

A 回答 (1件)

<link rel="shortcut icon">のタグを削除して、追加しなおしたら


出来るみたいです。(とりあえずFireFoxで試しただけですが)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja-JP">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="/image/AAA.png">
<title></title>
<script type="text/javascript">
<!--
function chgfavicon(){
var elm=document.getElementsByTagName("link");
elm[0].parentNode.removeChild(elm[0]);
var newfavicon =document.createElement("link");
newfavicon.setAttribute("rel","shortcut icon");
newfavicon.setAttribute("href","/image/BBB.png");
document.getElementsByTagName("head")[0].appendChild(newfavicon);
}
// -->
</script>
</head>
<body>
<button onclick="chgfavicon();">Change</button>
</body>
</html>
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!