Answer the question
In order to leave comments, you need to log in
Why is the alert not showing in the browser?
Given:
Project on node.js.
It has three files: "app.js" - it creates and starts the server, it also renders the "index.html" page.
"index.html" - it links another js file - "index.js".
In "index.js", in turn, there is a line "alert("something");"
Question: why is the alert not displayed in the browser? Everything is fine with the server and other things.
However, when you write like this (directly in "index.html"):
everything works <script>alert("something")</script>
Answer the question
In order to leave comments, you need to log in
app.js
var static = require( 'node-static' ),
port = 4000,
host = 'localhost',
http = require( 'http' );
var file = new static.Server( './public', {
cache: 3600,
gzip: true
} );
var server = http.createServer( function ( request, response ) {
request.addListener( 'end', function () {
file.serve( request, response );
} ).resume();
} );
server.listen( port, host, function() {
console.log( `Listening at http://${ host }:${ port }` );
} );
Are you sure that your index.js file was found and loaded?
Try importing it in a relative path like<script src="./index.js"> </script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question