1

On a freshly built, up to date Windows 10 computer with default settings, I get the following results:

HTA #1 Output: "5"

<script>
alert(document.documentMode)
</script>

HTA #2 Output: "7"

<!DOCTYPE html>
<script>
alert(document.documentMode)
</script>

HTA #3 Output: "9"

<head>
<meta http-equiv="X-UA-Compatible" content="IE=9">
</head>
<script>
alert(document.documentMode)
</script>

However, I have a report from a person on a Windows 10 machine that displays, as expected, "5" for HTA #1 and "9" for HTA #3, but also "9" for HTA #2. What setting would cause the observed behavior?

Note: This question differs from another similar question partly because it is targeted to HTA behavior (as opposed to the Internet Explorer application) and partly because the other question isn't clear about whether the results differ between documents with or without doctype declaration.

LesFerch
  • 1,540
  • 2
  • 5
  • 21
  • What build of Windows 10, there has been quite a few? – user692942 Aug 18 '21 at 06:35
  • Can confirm on my Windows 10 (21H1) OS Build: 19043.1151 it produces 5, 7 and 9. For the record, my Windows 10 installation is far from default. – user692942 Aug 18 '21 at 08:46
  • Might be useful - [Investigating Document Mode Issues](https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/samples/gg699340(v=vs.85)). – user692942 Aug 18 '21 at 08:56
  • Also, [Ref](https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/compatibility/jj676915(v=vs.85)) - "***Note** As of Internet Explorer 10, quirks mode behaves differently than it did in earlier versions of the browser. In Windows Internet Explorer 9 and earlier versions, quirks mode restricted the webpage to the features supported by Microsoft Internet Explorer 5.5. In Internet Explorer 10, quirks mode conforms to the differences specified in the HTML5 specification. For more info, see Specifying legacy document modes).*" – user692942 Aug 18 '21 at 09:00
  • 2
    Does this answer your question? [How to set FEATURE\_BROWSER\_EMULATION to IE8 mode?](https://stackoverflow.com/questions/4456490/how-to-set-feature-browser-emulation-to-ie8-mode) – user692942 Aug 19 '21 at 08:18
  • No. I read through that post before posting my question. There was no mention of HTAs, no mention about getting different results depending on whether a Doctype declaration is included, and there is an error in the information regarding HKCU and 64 bit which didn't inspire confidence. – LesFerch Aug 20 '21 at 00:20
  • HTAs are just a "skin" for the IE engine, it talks about the different emulation modes and in more detail. – user692942 Aug 20 '21 at 08:18
  • Yes, I understand that and I read the article multiple times. It has a link to another article (https://stackoverflow.com/questions/4612255/will-the-ie9-webbrowser-control-support-all-of-ie9s-features-including-svg/4613025) that almost answers the question, but it states "9999 (0x270F) - Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive." which is not true, at least for an HTA. With 9999 and no !DOCTYPE directive in the HTA, the document mode is 5. – LesFerch Aug 20 '21 at 13:33
  • Honestly, I think you're splitting hairs over technology that is defunct and likely obsolete by the time Windows 11 releases with Microsoft moving away from the Internet Explorer engine entirely in favour of Chromium. – user692942 Aug 21 '21 at 10:30
  • While Internet Explorer is clearly obsolete (and also defunct in Windows 11) the same is not true of HTAs. They continue to work just fine in Windows 11. While it would be nice to have full modern browser capabilities in HTAs, it's certainly not necessary. I just don't see any practical alternatives for easily creating a non-trivial GUI script that has full access to Windows PC resources. Is Electron or WebView2 a good alternative for the hobbyist, sysadmin, or academic? I don't think so. Is there some other alternative to HTAs that I'm missing? – LesFerch Aug 24 '21 at 02:09

1 Answers1

0

It's the result of a FEATURE_BROWSER_EMULATION setting. Specifically, this:

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]
"mshta.exe"=dword:00002328

or this:

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]
"mshta.exe"=dword:0000270f

When I originally tested the FEATURE_BROWSER_EMULATION setting, I only tested the value 11000 (x00002af8). That caused HTA #1 to report "11" so I assumed the pattern would follow down the line. That assumption was incorrect. A value of 9000 (x00002328) or 9999 (x0000270f) causes HTA #1 to report "5" and HTA #2 to report "9" as was seen on the machine in question.

LesFerch
  • 1,540
  • 2
  • 5
  • 21