2

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!

1 Answer 1

6

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();"];
Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.