HTML应用程序
HTML应用(英文:HTML Application, 缩写:HTA) 是一个使用HTML, 动态 HTML的Microsoft Windows应用, 它由Internet Explorer支持, 并且支持的其他脚本语言还有VBS和JScript. HTML用来创建用户接口, 脚本语言用来 创建程序主体. HTA执行当中没有互联网浏览器的安全模型的限制; 实际上, 它就像是一个被"完全信任"的应用.
大部分HTA文件的后缀为 .hta
.
可执行HTA的能力在1999年被引入Microsoft Windows, 同时发布的还有Microsoft Internet Explorer 5.[1] 在2003年12月9日这一技术申请了专利。[2]
使用
HTA给予开发者HTML和高级的脚本语言的共同特性. 它在微软的系统管理者在使用它们进行系统管理,从原型到“全面”的应用的过程中中非常受欢迎, 特别是在灵活性性和开发的速度中它非常重要。[3]
环境
执行

mshta.exe产生的例子
HTA使用mshta.exe
运行, 此外, 双击HTA文件也可以运行 . 该程序与Internet Explorer同时安装. mshta.exe
通过一个Internet Explorer渲染引擎(mshtml)实例来运行 HTA文件, 同时运行的还有需要的语言引擎 (例如 vbscript.dll).
HTA被视为带有 .exe
扩展名的可执行文件. 在当该文件被mshta.exe运行 (或该文件被双击), 它就会立即运行. 当被远程用浏览器运行时, 用户将会被询问, 在HTA被下载到本地之前, 用户可以选择下载或不下载; 如果选择保存,它可以简单的被按需运行.[4]
默认每个HTA被呈现为"标准模式内容(IE7标准模式) 和怪癖模式内容(IE5怪癖模式)", 但呈现方式可以被 X-UA-Compatible
标签更改.[5]
HTA引擎(mshta.exe)依赖于Internet Explorer. 从Windows Vista开始, 用户可以从系统中移除Internet Explorer , 但它将使引擎停止工作.
HTA在Internet Explorer 5 至 9中被完美支持. 更多版本, 例如10 and 11, 仍支持HTA但某些小功能被关闭.]
Security considerations
When a regular HTML file is executed, the execution is confined to the security model of the web browser, that is, it is confined to communicating with the server, manipulating the page's object model (usually to validate forms and/or create interesting visual effects) and reading or writing cookies.
On the other hand, an HTA runs as a fully trusted application and therefore has more privileges than a normal HTML file; for example, an HTA can create, edit and remove files and registry entries. Although HTAs run in this 'trusted' environment, querying Active Directory can be subject to Internet Explorer Zone logic and associated error messages.
开发
To customize the appearance of an HTA, an optional tag hta:application
was introduced to the HEAD
section. This tag exposes a set of attributes that enable control of border style, the program icon, etc., and provide information such as the argument (commandline) used to launch the HTA.[6] Otherwise, an HTA has the same format as an HTML page.
Any text editor can be used to create an HTA. Editors with special features for developing HTML applications may be obtained from Microsoft[7] or from third-party sources.[8]
一个存在的HTML文件(文件后缀为.htm
或 .html
, 一个例子) 可以只将文件后缀更改为 .hta
来更改为HTA文件.
例子
这是一个Hello World程序在HTA中的实现过程.
<HTML>
<HEAD>
<HTA:APPLICATION ID="HelloExample"
BORDER="thick"
BORDERSTYLE="complex"/>
<TITLE>HTA - Hello World</TITLE>
</HEAD>
<BODY>
<H2>HTA - Hello World</H2>
</BODY>
</HTML>
另请参阅
- Active Scripting
- Chromium Embedded Framework
- Google Chrome extension
- Intranet
- Firefox OS
- XUL 和 XULRunner - 一个Mozilla的跨平台应用程序, 它的语言和环境与HTML应用程序的机制相类似。
- Apache Cordova
- Pop-up ad
参考
- ^ Article ID:200874 in Microsoft Support, in Microsoft Support Knowledge Base
- ^ Microsoft wins HTML application patent
- ^ Introduction to HTML Applications (HTAs), in MSDN Library
- ^ Why Use HTAs, in MSDN Library, Introduction to HTML Applications
- ^ [1] Introduction to HTML Applications (HTAs) - Compatibility
- ^ HTA:APPLICATION Object, in MSDN Library, the complete specification of the tag
hta:application
- ^ HTA Helpomatic
- ^ HTAEdit, an editor for HTAs with a built-in debugger
外部链接
- HTML Component (HTC) Reference at MSDN. An HTC encapsulates specific functionality or behavior within HTAs.
- The Script Center, The Script Center, home of Hey, Scripting Guy! Blog
- Learn About Scripting for HTML Applications (HTAs), 一个学习HTA的网站