Home > Back-end >  javascript isn't running
javascript isn't running

Time:09-27

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

alert("my name")
<html>

<body>
  fvbnhjm
  <script type="text\javascript" 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

CodePudding user response:

text\javascript 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 \.

CodePudding user response:

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

  • Related