Link .js to html file


#1



Javascript Final Project


I am attempting to link my main.js file to the header in the html file.
My directory tree:
Desktop/Destiny/javascript/main.js

The html file is in the "Destiny" directory and the main.js is in the javascript directory.

I am supposed to create an alert in the .js file and link to the header of the html.


The html file is as follows: 

<!DOCTYPE html>

<HTML>

<head>
<script type="text/javascript" src="Destiny/javascript/main.js"></script></head>
<body>
</body>
</HTML>

****************************
The .js file is as follows:

alert("Here is an alert");
****************************

When I open the html file in the browser, no alert appears.


#2

@zainabrawat ^-------^


#3

Why don't you put them in the same directory, so you can link the JS with src="main.js"?
Also, you should make <HTML></HTML> lowercase.


#4

Well, Destiny is the main project folder, and javascript is a folder within the destiny folder. I just want to have a distinct folder for all javascript files.


#5

And I have made the html lowercase, thanks.


#6

@biesack.samlive.com If your HTML file is within Destiny as well, then you do not need to include that in the path to the javascript file.

Just put javascript/main.js.