I have been trying to get this method to run, but I couldn't get it to work. It was working when I kept my JavaScript methods within the HTML, but now that I moved the JavaScript into an external file, it is not doing anything:
This is my html:
<head>
    <title>TheNewTao Developer</title>
    <link rel="stylesheet" href="main.css" type="text/css">
    <script src="/script.js" type="text/javascript"></script>
</head>
<body onload="greetings()">
I want the method greetings() to run as soon as the page is loaded. This is my script.js file
function greetings() {
  var name = prompt('Hello, what is your name');
  document.getElementById('username').innerHTML = 'Welcome to the web ' + name;
}
All files are in the same folder. Does anyone know why it is not working?
 
     
     
    