[英]Script not loading in webview (Xaml/C#) windows phone 8.1
[英]C# windows phone 8.1 InvokeMember in WebView
我有一个包含此HTML代码的URL
<html>
<head>
<title>Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<form action="http://mySite.ir/search.html" method="POST">
<input onkeypress=FKeyPress(this); onkeydown=FKeyDown(this); size="25" type="text" name="query" value=""/>
<input type="submit" value="Search"/>
</form>
</html>
我想在TextBox上放一些东西,然后按下WebView上的ClickButton。 在C#Desktop我已经使用过这段代码>
webBrowser1.Document.GetElementById("textBoxV").SetAttribute("value", textBox1.Text);
webBrowser1.Document.GetElementById("pressButton").InvokeMember("submit");
但在Windows Phone 8.1中无法使用该方法。 请告诉我如何在Windows手机中按下该按钮?
您可以调用InvokeScriptAsync并在第一个表单上调用submit(index == 0)或按id获取表单,然后调用submit()。
await wview.InvokeScriptAsync("eval", new string[] { "var elem = document.forms[0].submit();"});
确保在WebView中加载HTML,否则会引发异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.