brainray
brainray

Reputation: 12884

mimic pressing a button on a webpage in the backgroud, for triggering an action

Pretend you have a button on an iOS GUI. Pressing this button should now trigger a button on a webpage (which triggers an action). While doing this, the webpage should not be visible. How can I do that?

My guess is, that I read and parse the webpage, and if I've found the button action, I would trigger it somehow. Since I'm not a web programmer, I wonder how to proceed or read on for such a task.

I need this task, because there is no JSON or XML webservice on the page that would make life easier.

Many thanks for any input

Upvotes: 0

Views: 131

Answers (1)

Luke
Luke

Reputation: 11476

Okay, let's say you've already loaded your webpage in an off-screen (or hidden) UIWebView, and the submit button on that webpage looked a bit like the following in code:

<form id="my_submit_button" etc... >

Just call the following:

NSString* javascript = @"document.forms['my_submit_button'].submit();";
[myUIWebView stringByEvaluatingJavaScriptFromString: javascript];

Hope this helps!

Upvotes: 1

Related Questions