html - How can I run Javascript from a local folder? -
html - How can I run Javascript from a local folder? -
i new javascript , can't seem load simple javascript file html file.
i have folder on desktop .html file , .js file
the .html file contains next html:
<html> <head> <title>simple page</title> </head> <body> <p> simple html page</p> <script src=“script.js”></script> </body> </html>
inside .js file have simple javascript text:
alert("hello world:);
when open .html file in browser text:
"this simple html page"
it doesn't run script. can't seem find way create .html file point .js script though in same folder on desktop. doing wrong? also, i've tried set javascript straight within html code (with ( tags) , doesn't work either.
what doing wrong? i've tried 2 different browsers. folder issue?
thanks.
three possibilities can see here:
your script has colon instead of double quote
if (1) copy/paste error - double quotes on "script.js" wrong type (if have copied/pasted code somewhere - type them manually)
javascript disabled in browser(some browsers such net explorer not load javascript unless served webserver such apache or iis example).
to test if browser issue place javascript in <script></script>
tag right before closing </body>
tag. if works using next code issue browser.
example:
<script> alert("hello world"); </script> </body><!--above script should placed before tag -->
javascript html
Comments
Post a Comment