JavaScript version in HTA
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.