0

Why doesn't this code get executed?

var password= prompt("Enter the passcode to enter the page"); alert(password); When I execute this code I just dont revice any alert...what is the problem???

7th Sep 2016, 11:01 AM
Fardad Fateh
7 odpowiedzi
+ 1
There is no error in the code. Where did you put it?
7th Sep 2016, 11:09 AM
Zen
Zen - avatar
+ 1
Did you include a script tag with a reference to your js file in your html? (This is not necessary if you are using Code Playground.) <script type="text/javascript" src="my_external_file.js"></script>
7th Sep 2016, 11:19 AM
Zen
Zen - avatar
+ 1
Yes, this is a script tag. Put this in your html. And of course, replace the name of the script in the src attribute with your script name. Then open the html page with your favorite browser, and the code should run. Alternatively, you can use the javascript console of your browser (CTRL+SHIFT+K on Firefox). No need for an html file that way, but you then have to type all of your commands. A probably better alternative would be to use Greasemonkey/Tampermonkey (for Firefox and Chrome respectively), and create userscripts. No need to have an html file, and you can set your favorite text editor (Notepad++ for example) to edit your scripts.
7th Sep 2016, 1:09 PM
Zen
Zen - avatar
0
I used an external js code and in <head> tag I wrote <script type="text/javascript" src="scripts.js"></script> And in addition to this code I have another alert in the scripts.js file and that alert executes...
7th Sep 2016, 11:13 AM
Fardad Fateh
0
Well this code is in notepad++ and I didnt understand you...<script type="text/javascript" src="scripts.js"> is a script tag isnt it?
7th Sep 2016, 11:25 AM
Fardad Fateh
0
My js file's name is scripts.js
7th Sep 2016, 1:02 PM
Fardad Fateh
0
was it in a function attribute
15th Sep 2016, 4:20 AM
Werner