Ios 检测POST方法/按钮单击UIWebView
我正在尝试处理此处的单击按钮: 代码如下:Ios 检测POST方法/按钮单击UIWebView,ios,swift,uiwebview,Ios,Swift,Uiwebview,我正在尝试处理此处的单击按钮: 代码如下: <form action="/contest-voting/" method="post" id="pimp-entities-contest-voting-form" accept-charset="UTF-8"><div><input type="hidden" name="nid" value="1200"> <input type="hidden" name="fb_id" value="">
<form action="/contest-voting/" method="post" id="pimp-entities-contest-voting-form" accept-charset="UTF-8"><div><input type="hidden" name="nid" value="1200">
<input type="hidden" name="fb_id" value="">
<input type="hidden" name="form_build_id" value="form-iZa3h_R56jG3BZpQCaktyWo8exlP8PnURETJEm0omUk">
<input type="hidden" name="form_id" value="pimp_entities_contest_voting_form">
Nutze deinen <input type="image" id="edit-facebook" name="facebook" value="Per Facebook abstimmen" src="http://www.pimp-your-school.de/sites/all/themes/pimp_foundation/images/icon-voting-fb.png" class="form-submit">-Account oder deine <div class="form-item form-type-textfield form-item-email">
<input placeholder="E-Mail-Adresse" type="text" id="edit-email" name="email" value="" size="60" maxlength="128" class="form-text">
<input type="image" id="edit-submit" name="submit" value="Per E-Mail-Adresse abstimmen" src="http://www.pimp-your-school.de/sites/all/themes/pimp_foundation/images/icon-voting-3.png" class="form-submit"></div></form>
Nutze deinen-deine账户
我尝试了所有这些StackOverflow链接,但这些链接都不起作用:
,
,
,
,
还有其他方法吗?我无法通过你的问题判断你是否试图提交表格,或者在提交表格时是否观察。但是如果你想提交表格,你可以这样做
func webViewDidFinishLoad(_ webView: UIWebView) {
// This adds an email to the email text field. This takes the id of the email text field.
webView.stringByEvaluatingJavaScript(from: "document.getElementById('edit-email').value = \"example@example.com\"")
// This submits the field. This takes the id of the form.
webView.stringByEvaluatingJavaScript(from: "document.getElementById('pimp-entities-contest-voting-form').submit()")
}
我不知道如何观察提交的表格,因为
func webViewDidStartLoad(_ webView: UIWebView)
在提交表单时似乎不会调用,因为通常,url更改时您会使用此函数。应该改为,但情况似乎并非如此。嘿,我只是在观察,而不是屈服。正如你所说,链接没有被调用,这很奇怪。有什么想法吗?无论如何,谢谢你的回答!我对web表单了解不多,但似乎当单击按钮时,web页面正在执行post请求,而不是浏览器。因此没有加载新的URL。我已经和UIWebView代理打过交道,但他们都没有被调用。因此,除非你的网页被更改为加载帖子URL,否则我认为UIWebView不够成熟,无法满足你的需要。。。非常感谢你!