Q:

Javascript doesn't work in html file

I have html file:
<html>
  <head>
    <script type="text/javascript" src="new.js"></script>

  </head>
  <body>
    <p id="contentBI" >you should click here! </p>
  </body>
</html>

and javascript file:
function doAlert() {
  alert("hi!");
}

function addevent () {
  theBI=document.getElementById("contentBI");
  theBI.addEventListener("click",doAlert);
}

document.addEventListener("load",addevent);

Javascript doesn't run.

A:

use window.addEventListener("load",addevent); instead of document.addEventListener("load",addevent);
DEMO

