uwpwebview调用动态JavaScript
这几天我学习了Windows通用应用程序。使用WebView时,我看到它可以调用html文件中的脚本,但是执行外部JavaScript脚本如何uwpwebview调用动态JavaScript,javascript,c#,win-universal-app,Javascript,C#,Win Universal App,这几天我学习了Windows通用应用程序。使用WebView时,我看到它可以调用html文件中的脚本,但是执行外部JavaScript脚本如何 WebView webview = new WebView(); webview.Navigate(new Uri("https://www.google.com")); string script = @" function getBodyHTML() { var innerHTML = document.getElement
WebView webview = new WebView();
webview.Navigate(new Uri("https://www.google.com"));
string script = @"
function getBodyHTML()
{
var innerHTML = document.getElementsByTagName('body')[0].innerHTML;
return innerHTML;
}
";
我想获得bodyHTML,可能使用如下内容:
// pseudo code
webview.IncludeScript(script);
string bodyHTML = webview.ExecuteScript("getBodyHTML()");
哎呀,要知道类似的问题也得到了回答 我可以这样做:
string[] arguments = new string[] {@"document.getElementsByTagName('body')[0].innerHTML;"};
try
{
string bodyHTML = await webview.InvokeScriptAsync("eval", arguments);
}
catch (Exception ex)
{
}
可能重复的