Why am I getting error when using setAttribute() every time I type it?

So I am using Vanilla JavaScript, and I am having trouble using setAttribute(). It is giving me errors every time I try to use it. I am trying to make a challenge without using a lot of HTML just CSS and JS. Here is the code.

<script>
window.onload = function () {
    var el = document.querySelector("#home");
    el.setAttribute("href", "http://oyopages.com/p/61b8ab61666e4dc7d5f630e0.html");
} 
</script>