CHM 查看器禁止在 Windows 10 上访问 JavaScript 中的 'window' 对象

CHM viewer forbids access to 'window' object in JavaScript on Windows 10

Windows 10 上的 CHM 查看器不允许我使用 JavaScript 中的 'window' 对象,尽管在 Windows 7 上它与相同版本完美配合Internet Explorer。

重现此问题: 将此代码复制到文件 'index.htm'

<!DOCTYPE html>
<html>
<body>
    <script>
    document.write("Inner width: " + window.innerWidth + "<br>");
    try
    {
        window.addEventListener('scroll', function(e)
        {
            document.write("Scroll<br>");
        } );
        document.write("All right.<br>");
    }
    catch (ex)
    {
        document.write("Exception: " + ex.message + "<br>");
    }
    </script>
</body>
</html>

然后将这段代码复制到一个文件中'Test.hhp'

[OPTIONS]
Binary Index=No
Compatibility=1.0
Compiled file=Test.chm
Default Window=>MainHelp
Default topic=index.htm
Display compile progress=Yes
Language=0x409 Englisch (USA)
Title=Testing

[WINDOWS]
>MainHelp="Testing",,,"index.htm",,,,,,0x40000,,0x0,[50,50,900,750],,,,,,,0

将两个文件复制到同一目录中,然后使用 Html Help Workshop 编译它们。

在 Windows 7 上按预期工作:

在 Windows10 上它在 Internet Explorer 中工作,但在 CHM 文件中不工作:

Windows 10 中似乎有安全限制,而 Windows 7 中没有。

是否有任何注册表项或任何 Internet Explorer 设置我可以修改以授予 CHM 查看器访问 'window' 对象的权限?


编辑: 在阅读了 Dai 的回答后,我发现了为什么它在 Windows 7 而不是 Windows 10 上有效。它没有任何关系使用 Windows 版本。原因是我的Windows7 另一个软件已经设置了注册表项

[HKLM\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION]
hh.exe = 9000

我可以在我的德语 Windows10 PC 上重现此行为。

将以下语句添加到 index.htm 文件的 <head> 部分。 即使 HTML 主题文件被编译成 .chm 帮助文件,这对我也适用。

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11"/>

例如:

<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11"/> 
</head>

导致以下帮助查看器 window:


编辑: SO 上针对以下问题给出了与 x-ua-compatible 相关的综合答案:

引自 Microsoft 文档 Use Enterprise Mode to improve compatibility

If you don't have IE11 installed anymore, you can download it from the Internet Explorer 11 download page. Also, if you use an earlier version of Internet Explorer, upgrade to IE11. Windows 7, Windows 8, and Windows 10 support IE11 so that you can continue using legacy apps even as you migrate to Windows 10 and Microsoft Edge.