Jaume
Jaume

Reputation: 3780

xcode parse or read html content loaded into webview

I am loading a jqueryMobile html page into a webview. Is there any method to read a parameter set on html file in order to then execute native functions? how and where to set it? any help would be appreciated! Thank you

Upvotes: 1

Views: 613

Answers (1)

Shameem
Shameem

Reputation: 14339

Let javascript do the work for you.

  1. Include a javascript function which returns the value as string. say getParam()
  2. When are finished with loading the HTML, use the stringByEvaluatingJavaScriptFromString: method of UIWebView (upon webViewDidFinishLoad)

Eg:

-(void)webViewDidFinishLoad:(UIWebView *)webView {
    NSString *param = [webView stringByEvaluatingJavaScriptFromString:@"getParam();"];
}

Upvotes: 3

Related Questions