0

Heyo! I'm using a random number generator to choose an icon. Then I set it to a setAttribute(). Trying to set it doesn't work. What am I doing wrong?

<!DOCTYPE html>

<html>
<head>
<script type="text/javascript">


    var number = Math.floor((Math.random() * 5) + 1);

    var ico = number + ".ico"


    setAttribute(href, ico);




</script>
<title>Cool Server People!</title>
<link rel="stylesheet" href="style.css">
<link rel="shortcut icon" href= "1.ico"/>
</head>
<body>
<div class="header">
    <h1>Cool Server People</h1>
</div>

<div class="space">

</div>  

<div class="blog">

    <a href="test-post.html" class="post">Blog Post</a>
    <p>asdfdasdfasdfasdfa</p>

</div>

  • You have to get a reference to the `` element (aware of `querySelector`?) to call its `setAttribute` method. You also want the string `'href'`, not the undeclared variable `href`. – Ry- Sep 25 '17 at 22:04
  • Possible duplicate of: [Changing website favicon dynamically](https://stackoverflow.com/questions/260857/changing-website-favicon-dynamically) – bazzells Sep 25 '17 at 22:07
  • What is your method setAttribute? – epascarello Sep 25 '17 at 22:25

0 Answers0