[Solved] Can’t attach local Javascript file to HTML


The src path is relative to the html file. If both are in the same directory, then try:

<script type="text/javascript" src="https://stackoverflow.com/questions/31767363/Application.js"></script>

if in a subdirectory

<script type="text/javascript" src="https://stackoverflow.com/questions/31767363/dirName/Application.js"></script>

if in a parent directory

<script type="text/javascript" src="https://stackoverflow.com/questions/31767363/Application.js"></script>

However, make sure that the JS file is somewhere in the hierarchy of the root directory of your website, that is the root folder that your web server uses.

2

solved Can’t attach local Javascript file to HTML