0
Why wont my is Java Script file run on android google chrome browser the is file is right next to the html trying and external
<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8" /> <title>first</title> <link rel="stylsheet" type="text/css" href="./css/style.css"> </head> <body>. <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/FrenchMarketPumpkinsB.jpg/350px-FrenchMarketPumpkinsB.jpg" height="150px" width="150px" border="1px" alt="" /> <script file="text/javascript" src="demo.js"></script> </body> </html>
16 Answers
+ 6
from what i can see here your
<link> tag has not been closed
idk if that should warrant the file not running tho
+ 1
tell more about how you running the file ? and what the javascript file does ?
by localhost , port forwarding and please correct english
+ 1
well I go into my folder click the saved html file and it displays the pumpkins but won't display the alert java file
+ 1
your folder is located in android ? did style loading ?
+ 1
Yes and that's the part I don't think I understand both files are right next to each other
+ 1
You need to correct file path in html file inside <script> and <link> to point to the local files like demo.js and style.css. If you use local image you also need to set <img> src to the local image.
+ 1
I think I understand could you give me an example using my code pref
+ 1
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<title>first</title>
<link rel="stylsheet" type="text/css" href="/storage/emulated/0/test/style.css">
</head>
<body>.
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/FrenchMarketPumpkinsB.jpg/350px-FrenchMarketPumpkinsB.jpg" height="150px" width="150px" border="1px" alt="" />
<script file="text/javascript" src="/storage/emulated/0/test/demo.js"></script>
</body>
</html>
+ 1
in above case index.html,style.css,demo.js is located in a folder named test in root of the internal storage.
You need to specify path in android format
+ 1
now try
+ 1
still not working won't i no why but I changed file name to make it simpler and in my case the folder is named project
+ 1
make all style and js internal and test if it is running or not ?
if there is anyone mistake the javascript will not work.
+ 1
I trust the java code as part of the html and it worked only as different files it won't run the external I had same problem with img so it got to be the path right this is a java code
alert("This is an alert box!");
+ 1
this correct and it is not java but java script (JS) java and java script are different.
+ 1
js I mean JS but yes so why isn't the js file running
0
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<title>first</title>
<link rel="stylsheet" type="text/css" href="/storage/emulated/0/Project/style.css">
</head>
<body>.
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/FrenchMarketPumpkinsB.jpg/350px-FrenchMarketPumpkinsB.jpg" height="150px" width="150px" border="1px" alt="" />
<script file="text/javascript" src="/storage/emulated/0/Project/js.js"></script>
</body>
</html>