HTA中的JavaScript版本 [英] JavaScript version in HTA

查看:184
本文介绍了HTA中的JavaScript版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道HTA文件使用的是什么版本的JavaScript。

Does anyone know what version of JavaScript is used by HTA files.

目前正在创建一些脚本文件 - 并尝试使用对象.defineProperty

Currently creating some script files - and trying to make use of Object.defineProperty

当作为HTA运行时 - 它会错误地指出Object不支持此属性或方法。我把它作为一个HTM文件运行只是为了检查 - 并且没有任何问题。

When running as an HTA - it errors stating that Object doesn't support this property or method. I've run it as an HTM file just to check - and there is no problem at all.

所以我只能假设 mshta。 exe 正在使用较旧的JavaScript引擎。任何人都可以确认这个吗?

So I can only assume that mshta.exe is using an older JavaScript engine. Can any one confirm this?

推荐答案

使用过的JavaScript(或JScript)版本取决于三件事:安装的Interner Explorer版本,使用文档类型声明(DTD)和 x-ua-compatible 元标记。

The used JavaScript (or JScript) version depends on three things: installed Interner Explorer version, used document type declaration (DTD) and x-ua-compatible meta tag.

虽然HTA由mshta运行。 exe,IE为应用程序提供了JavaScript和渲染引擎,因此后来关于JS版本的所有内容都代表了盒子模型,定位,CSS等,以及可用的API和HTML元素。

Though HTAs are run by mshta.exe, IE provides the JavaScript and rendering engines to applications, hence everything said later about JS versions, stands for box-models, positioning, CSS etc, and available APIs and HTML elements too.

如果您的系统中安装了IE11,则可以使用<!DOCTYPE html> <来使用最新版本的JavaScript ; meta http-equiv =x-ua-compatiblecontent =ie = edge/>

If you have IE11 installed into your system, you can use the latest version of JavaScript by using <!DOCTYPE html> and <meta http-equiv="x-ua-compatible" content="ie=edge" />.

当然,设置内容 IE = edge 不会覆盖旧版本的已安装IE,使用最新的可用模式。而不是 edge ,您可以使用IE版本号在使用较新的IE运行时降级应用程序。

Naturally, setting the content to IE=edge doesn't override an old version of the installed IE, the latest available mode is used. Instead of edge, you can use IE version numbers to downgrade the app when run with newer IEs.

省略DTD应始终删除应用程序以在Quirks模式下运行,在HTA的情况下类似于IE5。但是,在这种情况下,可以使用 x-ua-compatible 更改文档模式,但至少在IE8和& ;;中存在一些不一致。 9.如果不需要Quirks模式,使用DTD总是最安全的。

Omitting DTD should always drop the app to run in Quirks mode, which in the case of HTA is similar to IE5. However, in this case, the document mode can be altered with x-ua-compatible, but there were some inconsistencies at least in IE8 & 9. It's always safest to use DTD, if the Quirks mode isn't required.

使用DTD,但没有 x-ua-compatible 元标记HTA在IE7标准模式下运行(不支持 object.defineProperty(),它在IE9中引入。)

With DTD, but without x-ua-compatible meta tag HTAs are run in IE7 Standards mode (which doesn't support object.defineProperty(), it's introduced in IE9).

您可以在MSDN上阅读有关该主题的更多信息: HTML应用程序(HTA)简介

You can read more about the subject at MSDN: Introduction to HTML Applications (HTAs)

可以在以下位置找到JS和CSS的IE版本信息MSDN:

IE version info for JS and CSS can be found at MSDN:

JavaScript版本信息

Internet Explorer中的CSS兼容性

这是HTA文件的安全启动 ,当你想使用的时候最新可用版本:

Here's a "safe start" for a HTA file, when you want to use the latest available version:

<!DOCTYPE html>
<html>
<head>
<title>HTA</title>
<meta http-equiv="x-ua-compatible" content="ie=edge" />
// All link, style and script tags, or any code should be placed below the five lines above

您还可以使用 ScriptEngine 函数查找最新的脚本版本:

You can also use ScriptEngine functions to find out the latest script version:

ver = ScriptEngine() + ' V ';
ver += ScriptEngineMajorVersion() + '.';
ver += ScriptEngineMinorVersion() + '.';
ver += ScriptEngineBuildVersion();
alert(ver);

注意,这只显示浏览器提供的最新版本,文档模式没有影响到返回的值。

Notice, that this shows only the latest version provided by browser, document mode doesn't have an affect to the returned values.

这篇关于HTA中的JavaScript版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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