C#InvokeScript给出错误80020006 [英] C# InvokeScript gives error 80020006
本文介绍了C#InvokeScript给出错误80020006的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一段如下的代码
webBrowser.IsScriptEnabled = true;
webBrowser.InvokeScript("eval", "alert('hey')");
它给出现未知错误。错误:80020006
。你可以指导如何纠正这个错误。
It gives An unknown error has occurred. Error: 80020006
. Could you guide how to rectify this error.
推荐答案
有没有内置的浏览器 window.alert
Windows Phone中,但你可以绑定一条如下调用 WebBrowser.ScriptNotify
There is no built-in browser window.alert
in Windows Phone, but you can bind one as follows to call WebBrowser.ScriptNotify
//inside the page
window.alert = function (__msg) { window.external.notify(' + __msg + '); };
// in your C# code
this.webBrowser.ScriptNotify += new EventHandler<NotifyEventArgs>(Browser_ScriptNotify);
void Browser_ScriptNotify(object sender, NotifyEventArgs e)
{
MessageBox.Show(e.Value);
}
//later
this.CordovaView.Browser.IsScriptEnabled = true;
this.CordovaView.Browser.InvokeScript("alert", "ok");
在科尔多瓦,也有一个通知插件,您可以通过
On Cordova, there is also a Notification Plugin that you can plug by
window.alert = navigator.notification.alert;
只要确保能够在config.xml中通知插件
Just be sure to enable Notification Plugin in config.xml
<feature name="Notification">
<param name="wp-package" value="Notification"/>
</feature>
这篇关于C#InvokeScript给出错误80020006的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文