如何通过iOS(iPhone)代码在网页内按下java脚本事件按钮?

如何通过iOS(iPhone)代码在网页内按下java脚本事件按钮?,iphone,uiwebview,Iphone,Uiwebview,我正在为iOS(iPhone)编写一个应用程序 如何在网页中使用java脚本事件按下按钮?我需要写一个代码来按下这个按钮。然后将执行该事件。我会考虑它的工作结果 非常感谢你的帮助 您可以使用: document.getElementById('id-of-button').click(); 这将在按钮上执行单击事件 编辑:要在UIWebView中运行JavaScript,请使用stringByEvaluatingJavaScript:方法。例如: [webView stringByEvalua

我正在为iOS(iPhone)编写一个应用程序

如何在网页中使用java脚本事件按下按钮?我需要写一个代码来按下这个按钮。然后将执行该事件。我会考虑它的工作结果

非常感谢你的帮助

您可以使用:

document.getElementById('id-of-button').click();
这将在按钮上执行单击事件

编辑:要在UIWebView中运行JavaScript,请使用
stringByEvaluatingJavaScript:
方法。例如:

[webView stringByEvaluatingJavaScript:@"document.getElementById('id-of-button').click();"];

更新:
[self.webView stringByEvaluatingJavaScriptFromString:@“document.getElementById('id-of-button')。单击();”