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>

1st Nov 2018, 6:12 PM
Jaja-Dia
Jaja-Dia - avatar
16 Réponses
+ 6
from what i can see here your <link> tag has not been closed idk if that should warrant the file not running tho
1st Nov 2018, 6:16 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 1
tell more about how you running the file ? and what the javascript file does ? by localhost , port forwarding and please correct english
1st Nov 2018, 7:00 PM
Chandan Kumar Mandal
Chandan Kumar Mandal - avatar
+ 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
1st Nov 2018, 7:58 PM
Jaja-Dia
Jaja-Dia - avatar
+ 1
your folder is located in android ? did style loading ?
1st Nov 2018, 7:59 PM
Chandan Kumar Mandal
Chandan Kumar Mandal - avatar
+ 1
Yes and that's the part I don't think I understand both files are right next to each other
1st Nov 2018, 8:01 PM
Jaja-Dia
Jaja-Dia - avatar
+ 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.
1st Nov 2018, 8:04 PM
Chandan Kumar Mandal
Chandan Kumar Mandal - avatar
+ 1
I think I understand could you give me an example using my code pref
1st Nov 2018, 8:16 PM
Jaja-Dia
Jaja-Dia - avatar
+ 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>
1st Nov 2018, 8:19 PM
Chandan Kumar Mandal
Chandan Kumar Mandal - avatar
+ 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
1st Nov 2018, 8:20 PM
Chandan Kumar Mandal
Chandan Kumar Mandal - avatar
+ 1
now try
1st Nov 2018, 8:29 PM
Chandan Kumar Mandal
Chandan Kumar Mandal - avatar
+ 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
1st Nov 2018, 8:30 PM
Jaja-Dia
Jaja-Dia - avatar
+ 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.
1st Nov 2018, 8:31 PM
Chandan Kumar Mandal
Chandan Kumar Mandal - avatar
+ 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!");
1st Nov 2018, 8:36 PM
Jaja-Dia
Jaja-Dia - avatar
+ 1
this correct and it is not java but java script (JS) java and java script are different.
1st Nov 2018, 8:45 PM
Chandan Kumar Mandal
Chandan Kumar Mandal - avatar
+ 1
js I mean JS but yes so why isn't the js file running
1st Nov 2018, 8:47 PM
Jaja-Dia
Jaja-Dia - avatar
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>
1st Nov 2018, 8:28 PM
Jaja-Dia
Jaja-Dia - avatar