Reputation: 6632
This seems like a rather dumb question to ask but I would like to resolve this quickly and start working.I have a folder in which my html resides and I have the javascript files in a seperate folder called js
.I have tried to add the script like this:
<script type="text/javascript" src="js/gmaps.js">
and I have also tried like this:
<script type="text/javascript" src="./js/gmaps.js">
I have even tried like this:
<script type="text/javascript" src="/js/gmaps.js">
As far as I understand either of the first two should work:
/ root folder
./ current folder
../one folder up
The paths of the files are
/home/anr/Desktop/maps/server/client/js/gmaps.js
/home/anr/Desktop/maps/server/client/google_maps.html
The js file has window.onload and it also creates another script tag programmatically and adds it to the dom,after moving to the external script file I find that the map does not load
Upvotes: 0
Views: 2354
Reputation: 87
I also had a similar problem but not with the path. My problem is the encoding of the html file in my demo, change encoding to ASNI to fix problem.
Upvotes: 0
Reputation: 4286
<script type="text/javascript" src="js/gmaps.js"></script>
Tag should be closed
Upvotes: 0
Reputation: 458
Looks like you just need to close your script tag with a on the first example, which should work.
Upvotes: 2
Reputation: 7159
Try this,
<script type="text/javascript" src="js/gmaps.js"></script>
The script tag should be closed
Upvotes: 0
Reputation: 1023
Be sure that you are closing your tag as well. Once you have the correct relative path, your syntax should be:
<script type="text/javascript" src="relative_path_here"></script>
The following link could be helpful for setting the relative path in HTML: Basic HTML - how to set relative path to current folder?
Upvotes: 1