两种类型的 VBScript?

Two types of VBScript?

所以最近,我有一个朋友教我一些 VBScript。这是下面的代码。

help = MsgBox("Click on 'Yes'",vbYesNoCancel, "Orders")
WScript.Echo help

该文件名为 File.vbs,据我所知,.vbs 代表 Visual Basic 脚本文件。但最近,我一直在网上搜索,发现 VBS 是另一回事。它看起来像 htmlxml。像这样。

<% Option Explicit
 %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
     "http://www.w3.org/TR/html4/loose.dtd">
 <html>
    <head>
        <title>VBScript Example</title>
    </head>
    <body>
        <div><% 
        ' Grab current time from Now() function.
                ' An '=' sign occurring after a context switch (<%) is shorthand 
                ' for a call to the Write() method of the Response object.
        Dim timeValue = Now %>
        The time, in 24-hour format, is 
                <%=Hour(timeValue)%>:<%=Minute(timeValue)%>:<%=Second(timeValue)%>.
        </div>
    </body>
 </html>

谁能解释一下我看的是不是正确的语言之类的? 提前致谢!

没有两种类型的 VBScript,区别纯粹在于它的使用方式。

VBScript Scripting Language 不能 运行 独立:它依赖于脚本宿主,脚本宿主可以根据其执行的上下文采取各种形式。

对于客户端场景,有几种使用方法:

  1. 通过Windows Scripting Host which can execute .vbs and .wsf extension files (for more on WSF see Windows Script File).

  2. 通过 Internet Explorer (从 Microsoft Edge 开始弃用,以使其符合现代标准浏览器) 通过 <script> HTML 标签。

  3. 通过类似于 Internet Explorer 但限制较少的 HTA,旨在用于允许访问本地资源(否则将被视为不安全)的受控环境.它通常用于设计在企业 中使用的基于 Web 的界面(mshta.exe 包含在 Windows 的大多数版本中)

对于服务器端方案,选项更直接:

  • Classic ASP is a server-side script engine that incorporates VBScript as its default scripting language. Classic ASP runs as an ISAPI extension inside IIS and can be configured to process any Active Scripting Language (which to date includes VBScript and JScript, but there is also a custom implementation of Perl known as PerlScript 在非基于 IIS 的服务器上 运行).

    在第二个示例中,VBScript <%%> 周围的奇怪括号是经典 ASP 脚本引擎的一部分。它们被称为“内联代码块”:它们帮助经典 ASP 解释器在 Web 服务器返回最终 HTML 之前识别它需要处理的代码。调用 Classic ASP VBScript 是错误的,因为它有自己的完全独立于 VBScript 的对象模型——它包含 RequestResponseServer 等对象只能在 Classic ASP.

    的上下文中使用

有用的链接

  • A: VBScript support in Internet Explorer 11
  • A: Is it possible to use V8 in ASP?(经典架构解释ASP)