简体   繁体   中英

File won't save as JavaScript extension in Notepad++

I am trying to use an external JavaScript file in my HTML as follows:

<script src='MyScript.js'></script>

The issue is, I am getting the following error in the Web console:

Loading failed for the <script> with source "file:///F:/GIS%20Assessment%202/MyScript.js".

I have realised that MyScript is not saved as having the JavaScript extension, in my documents it says it's a "File" rather than a JavaScript file. I have tried changing the language to JavaScript and saving as a JavaScript file as soon as I save it in my folder it just converts to a generic file!

What do I do? How do I fix this and save my scripts as JavaScript?

This isn't really a programming question, and is likely to be closed, but to force it to have the extension, simply enclose the filename (with the extension) in quotes.

"MyScript.js"

我知道这篇文章已经有一年多了,但我发现当我在保存文件时输入大写的文件扩展名时它起作用了:“myfile.JS”而不是“myfile.js”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM