summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/onload_change_favicon.html
blob: 49a894385f8703a6150eb4c99e9b58d7ef911d6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<html>
<head>
<title></title>
<link rel='icon' href='test.png'>
<script type='text/javascript' language='javascript'>
function removeLinkIfExists() {
  var docHead = document.getElementsByTagName("head")[0];
  var links = docHead.getElementsByTagName("link");
  for (var i=0; i<links.length; i++) {
    var link = links[i];
    if (link.type=="image/x-icon" && link.rel=="shortcut icon") {
      docHead.removeChild(link);
      return; // Assuming only one match at most.
    }
  }
}

function addLink(iconURL) {
  var docHead = document.getElementsByTagName("head")[0];
  var link = document.createElement("link");
  link.type = "image/x-icon";
  link.rel = "shortcut icon";
  link.href = iconURL;
  removeLinkIfExists();
  docHead.appendChild(link);
}

function OnLoad() {
 addLink("test1.png");
}

</script>
</head>
<body onload='OnLoad();'>
<a name='test'>
</body>
</html>