任何Url脚本通知窗口10 webview

问题描述:

从Windows 8.1,AllowedScriptNotifyUris webview的属性获取过时和强度要求设置在ApplicationContentUriRules下的包清单文件中的URL。任何Url脚本通知窗口10 webview

它不会允许在URL匹配标准中写入*,如下所述。

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

我不知道是什么网址将在WebView中被加载,我想要么所有的URL通知脚本或在清单文件动态地添加URL任何其他方式。

+0

是你能明白这一点? – CodeR

+0

@CodeR编号让我知道,如果你发现任何解决方案 –

+0

做https:// *而不是只是* – CodeR

要启用外部网页触发ScriptNotify事件时 调用window.external.notify,你必须包括页面的URI在应用清单的 ApplicationContentUriRules部分。 (你可以做到这 在Microsoft Visual Studio中的 Package.appxmanifest设计师的内容URI的选项卡。)已对此列表中的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

您应该为所有子域添加通配符也是如此。 事情是这样的:

<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" /> 

小心这一点,因为任何网址您的应用程序(的WebView)中打开它会暴露所有的WinRT API的。您可以在webview上使用MSWebViewNavigationStarting事件来监视您的webview中的所有导航。

+1

这认证失败!你必须对域进行硬编码 – CodeR

如上所述,原因在于URI规则。 Here is the answer

这是我工作的本地主机例如: enter image description here