Reputation: 14622
I am writing an application for iOS (iPhone).
How to press a button with java-script event inside a web-page? I need to write a code to press this button. Then the event will be executed. And I'll take result of it's work.
Thanks a lot for help!
Upvotes: 2
Views: 2069
Reputation: 55544
You can use:
document.getElementById('id-of-button').click();
This will perform a click event on the button.
EDIT: to run JavaScript in a UIWebView use the stringByEvaluatingJavaScript:
method. Eg:
[webView stringByEvaluatingJavaScript:@"document.getElementById('id-of-button').click();"];
Upvotes: 6