skip to Main Content
<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


  1. 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 structure

    • some folder
      • js
        • script.js
      • some inner folder
        • your HTML

    Since 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.

    Login or Signup to reply.
    1. If you are not used any folder you can follow this script link: <script src="./your file name"></script>

    2. if you are used any folder you can follow this script link: <script src="./your folder name/your js file name"></script>

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search