CHM查看器禁止在Windows 10上的JavaScript中访问“窗口”对象

问题描述 投票:0回答:1

[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帮助工作室进行编译。

在Windows 7上可以正常使用:

JavaScript can access window object in CHM file on Windows 7

在Windows 10上,它可以在Internet Explorer中使用,但不能在CHM文件中:

JavaScript cannot access window object in CHM file on Windows 10

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

是否有任何注册表项或Internet Explorer设置可以修改以赋予CHM查看器访问“窗口”对象的权限?

javascript internet-explorer chm
1个回答
0
投票

我可以在我的德语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>

将显示以下帮助查看器窗口:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.