I am new to JavaScript. When I am trying the following code my js files are not getting linked and the JavaScript code from the html page is not executed :
Both html and JavaScript files are at the same path.
MY html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;>
<title>JS Code</title>
</head>
<body>
HTML
<script type="text/javascript" src="script.js">
debugger;
document.write("HI i am from HTML with js code")
nowCall1();
function nowCall1(){
document.write("-Js.")
//peakOil(changeCivilisationCallback);
}
</script>
</body>
</html>
script.js:
function peakOil(callback) {
document.write("HI i am from Js");
callback(); // the parentheses mean the function is executed!
}
function changeCivilisationCallback(){
document.write("HI i am from changeCivilisationCallback");
}
function nowCall(){
document.write("Js.")
//peakOil(changeCivilisationCallback);
}
But when I try to remove scr attribute put all code in html script is working. Why when I try to put code in js file, it is not executed. I am facing problem in debugging in google chrome browser.
Please help me understand javas cript, thanks in advance.