最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

JavaScript version in HTA - Stack Overflow

programmeradmin3浏览0评论

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

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

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.

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

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

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

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.

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

Share Improve this question edited Jun 24, 2017 at 0:11 Alexander O'Mara 60.5k19 gold badges172 silver badges181 bronze badges asked Oct 24, 2013 at 13:48 DarrenNavitasDarrenNavitas 2391 gold badge3 silver badges11 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 22

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.

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.

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" />.

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.

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.

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).

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

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

JavaScript version information

CSS Compatibility in Internet Explorer

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

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.

发布评论

评论列表(0)

  1. 暂无评论