我正在尝试调用 JavaScript 方法WebBrowser
:
WebBrowser webBrowser = new WebBrowser();
webBrowser.NavigateToString(html);
webBrowser.LoadCompleted += ((s, r) =>
{
try
{
object tmp = webBrowser.InvokeScript("GetData");
}
catch (Exception exc)
{
}
});
这是HTML
:
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title></title>
<script type="text/javascript">
function GetData ()
{
return 50;
}
</script>
但是当我用以下命令调用 javascript 时:
object tmp = webBrowser.InvokeScript("GetData");
I get Exception
:
Message:
An unknown error has occurred. Error: 80020006.
权益追踪:
at Microsoft.Phone.Controls.NativeMethods.ValidateHResult(Int32 hr)
at Microsoft.Phone.Controls.WebBrowserInterop.InvokeScript(String scriptName, String[] args)
at Microsoft.Phone.Controls.WebBrowser.InvokeScript(String scriptName)
at YouTube.YouTubeExtractor.<>c__DisplayClass1.<ExtractVideoById>b__0(Object s, NavigationEventArgs r)
您需要设置WebBrowser.IsScriptEnabled
to true
(it is false
默认情况下)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)