<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="../css/style-index.css">
<script type="text/javascript" src="../js/script.js"></script>
</head>
in javascript is:
alert(‘test’)
external js is not connecting to html
structure: https://cdn.discordapp.com/attachments/1027105980900708442/1232712295893827635/image.png?ex=662a744a&is=662922ca&hm=5e90d125df3525f31584806fbdc41e91941442f596890bd8c0266e4ab76ca4b4&
edit: I also tried to rename project folder to remove all spaces
2
Answers
Your
../js/script.js
is specifying that your script.js is located outside of the folder your page is located, inside a js folder and a script.js inside of it, suggesting this structureSince script.js is not loaded, either it does not exist on that place, or some privileges are lacking. Most frequently this kind of problem arises when you moved things around and the relative path that was correct earlier is no longer correct. If that’s the case, then a path of
/js/script.js
instead could solve your problem, as long as the js folder is inside the root folder.Make sure the right privileges are allowed, your webserver allows the mimetype of Javascript files and the file exists.
If you are not used any folder you can follow this script link:
<script src="./your file name"></script>
if you are used any folder you can follow this script link:
<script src="./your folder name/your js file name"></script>