I am a complete node.js newbie and struggling with the basics.I have a html file and I would like to call external javascript file in the html page using node.js in local host environment.
JS:
var http = require('http'),
fs = require('fs');
fs.readFile('HtmlPage.html', function (err, html) {
if (err) {
throw err;
}
});
http.createServer(function(request, response) {
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(html);
response.end();
}).listen(8000);});
HTML:
<script type="text/javascript" >
function validation() {
alert("Hai");
var fs = require("JavaScript1.js");
}
</script>