I am trying to use Javascript code I wrote in a separate file with HTML. The code for the HTML document is as follows:
<!DOCTYPE html>
<html>
<a href="javascript:showAlert()">Show Alert!</a>
<script type="text/javascript" src="Users/Home/Documents/MyExternalScript.js"> </script>
</html>
and the Javascript file:
function showAlert(){
alert("I am an alert box!");
}
The Javascipt code works perfectly well when put in the HTML file itself, but seperating it into a different file causes: an Uncaught Reference Error on showAlert().
I have double checked the path a dozen time and tried just removing the path and leaving the name as they are in the same directory. I have also tried removing the file extension... I've even tried adding the script tag and body above the anchor tag. Nothing works.
Could anyone please explain to me where I am going wrong?