1

从 Windows 8.1 开始,AllowedScriptNotifyUriswebview 的属性被废弃,并且强烈要求ApplicationContentUriRules在包清单文件下设置 URL。

它不允许写入*如下所述的 url 匹配条件。

<uap:ApplicationContentUriRules>
    <uap:Rule Match="*" Type="include" WindowsRuntimeAccess="all" />
</uap:ApplicationContentUriRules>

我不确定将在 webview 中加载什么 URL,我希望所有 url 都通知脚本或任何其他在清单文件中动态添加 URL 的方式。

4

3 回答 3

1

要使外部网页能够在调用 window.external.notify 时触发 ScriptNotify 事件,您必须在应用清单的 ApplicationContentUriRules 部分中包含页面的 URI。(您可以在 Microsoft Visual Studio 中 Package.appxmanifest 设计器的 Content URIs 选项卡上执行此操作。)此列表中的 URI 必须使用 HTTPS,并且可能包含子域通配符(例如 https: //.microsoft.com),但它们不能包含域通配符(例如 https:// .com 和 https:// .)。清单要求不适用于源自应用程序包、使用 ms-local-stream:// URI 或使用 NavigateToString 加载的内容。

来自https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.webview.aspx

于 2015-10-21T01:49:06.360 回答
0

您还应该为所有子域添加通配符。像这样的东西:

<uap:Rule Match="https://*" Type="include" WindowsRuntimeAccess="all" />
<uap:Rule Match="https://*.*" Type="include" WindowsRuntimeAccess="all" />
<uap:Rule Match="https://*.*.*" Type="include" WindowsRuntimeAccess="all" />
<uap:Rule Match="https://*.*.*.*" Type="include" WindowsRuntimeAccess="all" />
<uap:Rule Match="https://*.*.*.*.*" Type="include" WindowsRuntimeAccess="all" />
<uap:Rule Match="https://*.*.*.*.*.*" Type="include" WindowsRuntimeAccess="all" />
<uap:Rule Match="https://*.*.*.*.*.*.*" Type="include" WindowsRuntimeAccess="all" />

请注意这一点,因为它会将所有 WinRT API 暴露给您的应用程序(webview)内打开的任何 url。您可以使用MSWebViewNavigationStartingwebview 上的事件来监视 webview 中的所有导航。

于 2015-10-31T18:26:39.573 回答
0

如上所述,原因在 URI 规则中。这也是答案

这是我的本地主机工作示例: 在此处输入图像描述

于 2016-07-27T08:17:55.367 回答