我试图在我的中调用 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");
我得到Exception
:
信息:
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)