skip to Main Content

i wrote this html document and the script isn’t running

alert("my name")
<html>

<body>
  fvbnhjm
  <script type="textjavascript" src="JavaScript.js">
  </script>
</body>

</html>

i installed code runner in vs code and the only thing that i added to settings.json is this

"code-runner.saveAllFilesBeforeRun": true,
"code-runner.saveFileBeforeRun": true,
"code-runner.executorMapByFileExtension": {

    ".js": "cd $dir $$ start $fileName",
    ".html": "cd $dir && start $fileName"
},

javascript isn’t disabled in my browser, i don’t need node.js here but i installed it

2

Answers


  1. textjavascript isn’t the correct type for javascript.

    You can omit the type attribute, but if you’re going to include it you need a / instead of .

    Login or Signup to reply.
  2. Let’s see your folder structure, make sure you have type a valid path to your js file.

    Looking for simple way to type the path? Just right click on your js file and click copy path. Then, paste it in src="file.js".

    <html>
    
    <body>
      fvbnhjm
      <script type="text/javascript" src="JavaScript.js">
      </script>
    </body>
    
    </html>

    You can read more about it in this thread.

    Thank you

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