Windows Script Host能运行.js文件。

huangapple go评论80阅读模式
英文:

Can Windows Script Host run a .js file

问题

为了一个课程项目,我需要打开一个名为script.jsjavascript文件,以编辑它使index.html正常工作。

但是每次我点击它,都会弹出一个消息说,'您要打开此文件吗?'。在我点击打开后,会出现一个错误消息,说Windows脚本主机无法打开此文件。出于隐私考虑,我不能发布它说什么。

我已经去过多个网站寻找答案。由于这是Windows,我去了Microsoft,但他们说这更像是程序员的问题,建议我查看像stackoverflow.com这样的网站。

在那之前,我已经重新启动了电脑,还尝试从Chrome和Firefox下载。但仍然无法解决。我需要打开文件来完成这个项目

这也是一台新电脑。我还尝试在旧电脑上打开,但仍然无法打开

我是如何得到这个文件的:

我在2020年1月1日从课程网站上下载了链接。

然后它进入了文件资源管理器。

如果单击index.html(它在Internet Explorer中打开),README.md(在WordPad中打开)和style.css(在记事本中打开),它们都能正常打开。但是使'index.html'工作的代码(script.js)无法打开。

这一切都在一个以.zip结尾的文件夹中。

我是新手javascript,所以我真的不明白发生了什么。

脚本是否损坏了?还是已过时了?Windows是否可以运行javascript文件?我几乎认为这可能是问题所在。

我查看了这个链接:https://www.youtube.com/watch?v=vOFuUNpLCQE,但我发现我没有'enabled'。

我真的需要帮助,因为我在2020年2月29日有截止日期。

您能从Windows切换到同一台计算机上的其他类型吗?

英文:

For a course project, I need to open a javascript file, namely script.js, to edit it to make index.html work.

But every time I click it, a message that says, 'Do you want to open this file?' comes up.After I click open, An error message comes ands says windows script host can't open this file. I can't post what it says for privacy's sake.

I've gone to multiple sites for answers.Since it is a windows, I went to Microsoft, but they said it is more of a programmers problem and that I should check out websites like stackoverflow.com.

Before then I had restarted the computer, and I also tried downloading from Chrome and Firefox.But still can't get it resolved. I need the file to open to complete the project.

This is also a new computer. I also tried opening on older computer,but it still didn't open.

How I got the file:

I downloaded the link from the course website on 1/1/2020

Then it went to File explorer.

If you click index.html (it opens with internet explorer) ,README.md (opens in wordpad),and style.css(opens with notepad).
It's the code(script.js) that makes 'index.html' work that won't open.
It's all inside a folder that ends in .zip

I'm new to javascript, so I really don't understand what's going on.

Is there something about the script that is corrupted? Or is it outdated? Can windows even run a javascript file? I'm almost thinking that is the problem.

I checked this link: https://www.youtube.com/watch?v=vOFuUNpLCQE , but I found I don't have 'enabled'

I really need help because I have a deadline on 29 February 2020.

Can you switch from windows to another type on the same computer?

答案1

得分: 1

  1. 打开您喜欢的编辑器,例如 Visual Studio Code、Sublime Text、Atom 或 Brackets。
  2. 从“文件”菜单中选择“打开”。
  3. 从对话框中选择您的 JS 文件。

在某些情况下,您可能希望配置您的文件管理器(例如 Windows Explorer 或 macOS Finder)以默认在您选择的编辑器中打开 JS 文件。

运行一个 JS 文件将取决于它设计用于运行的环境。例如,嵌入在网页中的 JS 通过在 HTML 文档中链接到它的<script>元素,然后在Web浏览器中打开该文档来运行,而设计用于与Node.js一起使用的命令行程序通常在命令行上使用node XXXXXXX.js或通过npmpackage.json配置运行。Photoshop 插件是不同的。经典 ASP 中的服务器端 JS 又是不同的。依此类推。

英文:

Presumably, the goal is to edit the JavaScript file.

  1. Open your prefered editor. e.g. Visual Studio Code, Sublime Text, Atom or Brackets.
  2. Pick "Open" from the "File" menu
  3. Pick your JS file from the dialog

At some point you may wish to configure your file manager (e.g. Windows Explorer or macOS Finder) to open JS files in your editor of choice by default.


To run a JS file will depend on what environment it is designed to run in. e.g. JS embedded in a web page is run by linking to it with a &lt;script&gt; element in an HTML document and then opening that document in a web browser, while a command line program designed for use with Node.js is generally run with node XXXXXXX.js on the command line or via npm and a package.json configuration. Photoshop plugins are different. Server-side JS in classic ASP is different again. And so on.

huangapple
  • 本文由 发表于 2020年1月3日 17:17:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/59575855.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定