So I was looking to create a UIBarButton, via IBOutlet, and send a JavaScript code to the WebView through this button. This is what I have so far but it keeps returning an error:
ViewController.m
- (IBAction)emailCodePhone:(id)sender {
NSURL *url = [NSURL URLWithString:@"javascript:location.href="mailto:[email protected]?body="+document.getElementById("code").value;"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webViewPhone loadRequest:requestObj];
}
ViewController.m Error

javascript:location.href="mailto:[email protected]?body="+document.getElementById("code").value;
^ This being the JavaScript code I want sent to the UIWebView so whatever's located in the Textarea (who's ID is code), will be emailed to [email protected].
Please also specify if theres an easier way to do this.