在 Notepad++ 中编译/运行 Javascript [初学者问题]

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4818236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 14:15:41  来源:igfitidea点击:

Compiling/ running Javascript in Notepad++ [beginner question]

javascriptnotepad++

提问by MetroGnome

I am a beginner programmer. I have a limited knowledge of javascript, but I have only worked in an IDE. I am currently following Lifehacker's programming series which teaches javascript. I have downloaded Notepad++ and have completed a program, but I am not sure of the steps to run it. In the video, the user is able to just send the program to a browser and the code runs from there.

我是一个初级程序员。我对 javascript 的了解有限,但我只在 IDE 中工作过。我目前正在关注 Lifehacker 的教授 javascript 的编程系列。我已经下载了 Notepad++ 并完成了一个程序,但我不确定运行它的步骤。在视频中,用户只需将程序发送到浏览器,代码就会从那里运行。

Here is the video for reference: http://bit.ly/gUsMd3

这是供参考的视频:http: //bit.ly/gUsMd3

Thanks! (note: i am a beginner to both programming and this site so any constructive criticism is welcome)

谢谢!(注意:我是编程和本网站的初学者,因此欢迎任何建设性的批评)

回答by Merijn

Javascript does not need to be compiled, you can put it between <script>and </script>in a file, save it as something.html and open it in your browser.

使用Javascript不需要进行编译,你可以把它之间<script></script>在文件中,保存为something.html并在浏览器中打开它。

Java needs to be compiled, but that is something completely different.

Java 需要编译,但那是完全不同的东西。

回答by Anvesh_vs

Just save the sample code to a file, such as "example.html", and then open that file in a browser.

只需将示例代码保存到一个文件中,例如“example.html”,然后在浏览器中打开该文件。

<html>
<script>
alert("hi");
</script>
</html>

回答by aks

To run JavaScript with Notepad++,

要使用 Notepad++ 运行 JavaScript,

  1. Type your JavaScript code in Notepad++.
    For instance, type the code
    window.alert("Hello world!");
    in Notepad++.
  2. Now, enclose your code with <script>and </script>tags. The above code now becomes

    <script> window.alert("Hello world!"); </script>

  3. Save the file with a .htmlextension.

  4. Now, click on Run -> Launch in Chrome. The JavaScript code will be run in the Chrome browser.

  5. If you modify the code, simply save the changes (Ctrl+s) in Notepad++. Then press Alt+Tabto return to Chrome. Press the Refresh button to run the changed code.

  1. 在 Notepad++ 中键入您的 JavaScript 代码。
    例如,
    window.alert("Hello world!");
    在 Notepad++ 中键入代码。
  2. 现在,用<script></script>标签将您的代码括起来。上面的代码现在变成

    <script> window.alert("Hello world!"); </script>

  3. 使用.html扩展名保存文件。

  4. 现在,单击Run -> Launch in Chrome。JavaScript 代码将在 Chrome 浏览器中运行。

  5. 如果您修改代码,只需在 Notepad++ 中保存更改 ( Ctrl+ s)。然后按Alt+Tab返回 Chrome。按刷新按钮运行更改后的代码。

回答by Michal

You can also download a console plugin that would allow you to execute java scripts without leaving Notepad++. See this videofor reference:

您还可以下载一个控制台插件,它允许您在不离开 Notepad++ 的情况下执行 Java 脚本。请参阅此视频以供参考: