下面的代码在 Windows 8 中运行,当进入 Windows 8.1 通用应用程序时,它显示将 URL 分配给 wv1.AllowedScriptNotifyUris 时未实现的错误方法。
XAML 代码:
<WebView Name="wv1" ScriptNotify="wv1_ScriptNotify_1" LoadCompleted="wv1_LoadCompleted_1"/>
Cs代码:
private async void BrowserPage_Loaded(object sender, RoutedEventArgs e)
{
wv1.Navigate(new Uri("http://www.google.com/search?q=" + "Devi", UriKind.RelativeOrAbsolute));
}
private void wv1_LoadCompleted_1(object sender, NavigationEventArgs e)
{
var absolutepath = e.Uri.Host.ToString() + e.Uri.AbsolutePath.ToString().Substring(0, e.Uri.AbsolutePath.ToString().LastIndexOf('/') + 1);
allowedUris.Add(new Uri(e.Uri.ToString()));
wv1.AllowedScriptNotifyUris = allowedUris;//error coming in this line
string[] args = { "this.newfunc_eventHandler=function(e){e.cancelBubble = true;var dataValue= document.selection.createRange().htmlText.toString();window.external.notify(dataValue);}" };
wv1.InvokeScript("eval", args);//error also in this line
string[] arg = { "document.body.addEventListener('copy',newfunc_eventHandler,true);" };
wv1.InvokeScript("eval", arg);//error also in this line
}
在 Windows 8 应用程序中,此代码用于在 web 视图页面中单击复制按钮时启用脚本。但是当在分配 url 和脚本时进入 windows 8.1 通用应用程序时,它返回方法未实现错误。请帮助解决这个问题...