0

i got a webview and i would like to capture an input from a webview HTML form. i have tried but i cant can some one help me please

this is my webview code

        // Init Web View
    UIWebView *webView;
    webView = [[UIWebView alloc] initWithFrame:boundsRect];
    webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    webView.scalesPageToFit = YES;
    webView.contentMode = UIViewContentModeCenter;
    webView.multipleTouchEnabled = NO;
    webView.userInteractionEnabled = YES;
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
    [self addSubview:webView];
    [webView release];
    return self;

To get value from webView, i used below code.

NSString* value = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('text').value"]‌​; 
NSLog(@"got: %@",value); 
10
  • i have tried with this : NSString* value = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('text').value"]; NSLog(@"got: %@",value); Commented Jan 13, 2014 at 14:37
  • And the problem is ? -stringByEvaluatingJavaScriptFromString: return nil ? Commented Jan 13, 2014 at 15:14
  • yes i doen't return any thing Commented Jan 13, 2014 at 15:16
  • it return an empty string @"" or nil ?? not 'anything' ... Commented Jan 13, 2014 at 15:20
  • 1
    To execute it after an HTML button is pressed see : stackoverflow.com/questions/6869199/… Commented Jan 13, 2014 at 15:30

1 Answer 1

0

You could look into how phonegap http://phonegap.com/ solves this.

Sign up to request clarification or add additional context in comments.

Comments

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.