如何引用另一个JScript文件? [英] How to reference a JScript file from another one?

查看:97
本文介绍了如何引用另一个JScript文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JScript和WSH编写一些服务器端脚本。脚本变得很长,一些常见的函数和变量更适合我在各种脚本实例中包含的通用库脚本。

I am writing some server-side scripts using JScript and WSH. The scripts are getting quite long, and some common functions and variables would fit better in a general library script which I included in my various script instances.

但是,我找不到一种方式引用另一个JScript文件。有一会儿,我读取文件内容并将其传递给 eval()可能会有效。但是,正如它在 MSDN 上所说:

But, I cannot find a way reference one JScript file from another. For a moment, I though reading the file contents and passing it to eval() could work. But, as it says on MSDN:


请注意,封闭程序看不到eval语句中定义的新变量或类型。

Note that new variables or types defined in the eval statement are not visible to the enclosing program.

有没有办法包含/引用另一个JScript文件?

Is there any way to include/reference a JScript file from another one?

推荐答案

尝试使用 Windows脚本文件。它基本上是一个XML文档,允许您包含多个脚本文件并定义多个作业等。

Try using a Windows Script File. It's basically an XML document which allows you to include multiple script files and define multiple jobs, amongst other things.

<!-- MyJob.wsf -->
<job id="IncludeExample">
  <script language="JScript" src="MyLib1.js"/>
  <script language="JScript" src="MyLib2.js"/>
  <script language="JScript">
    WScript.Echo(myLib1.foo());
    WScript.Echo(myLib2.bar());
  </script>
</job>

这篇关于如何引用另一个JScript文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆