让 "mark of the web" 在 Microsoft Edge 中工作?

Make "mark of the web" work in Microsoft Edge?

我想将 HTML 文件保存到磁盘,并使其可以在大多数浏览器中打开而不会出现警告(无网络服务器场景)。

对于 IE,我通常使用 "mark of the web",大多数浏览器(特别是 Firefox 和 Chrome)安全地忽略了它。 IE 在找到该 web 标记后也表现正常,没有显示任何警告。您可以查看 MSDN.

中的网络标记。

现在是问题。 Microsoft Edge 看到这个 "mark of the web" 震惊并停止执行包含的 javascripts 文件。我勒个去 ?!如果我删除 "mark of the web" 并在 Edge 中打开文件,它会正常打开(没有警告,并且会执行 javascripts)。

我可以让 IE 和 Edge 对同一个文件工作吗?

index.html

<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->
<html>
<head>
    <script src="foo.js" ></script>
</head>
<body>
</body>
</html>

foo.js

 alert('i am executed');

以上根本不会在 Edge 中执行(如果从文件系统打开)!如何实现?

您还需要 foo.js 上的 mark-of-the-web。有 several ways 可以将 mark-of-the-web 应用到 non-HTML 文件——您可以将其完整性级别设置为 "low":

icacls foo.js /setintegritylevel low

或者您可以添加带有区域标识符的备用数据流:

powershell -c add-content foo.js -stream Zone.Identifier -value "[ZoneTransfer]","ZoneId=3"

或者最简单的方法可能是将 index.html 重命名为 index.htm,然后将 foo.js 放入名为 index_files 的目录中。始终允许加载该目录中的任何内容,即使它没有自己的 mark-of-the-web.