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:someone@something.com?body="+document.getElementById("code").value;"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webViewPhone loadRequest:requestObj];
}
ViewController.m Error

javascript:location.href="mailto:someone@something.com?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 someone@something.com.
Please also specify if theres an easier way to do this.
The error is being thrown because your string is ending prematurely at the first quotation mark inside it. You need to “escape” the quotations within your string with a backslash:
NSURL *url = [NSURL URLWithString:@"javascript:location.href=\"mailto:...