Dmitry
Dmitry

Reputation: 14622

How to press a button with java-script event inside a web-page by code for iOS (iPhone)?

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

Answers (1)

Jonathan.
Jonathan.

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

Related Questions