0

I have a function/method in .html file and I need to call that function from objective C code. I have a page with UIWebView and we need to call and pass few parameters to javascript function in .html file. Please let me know if anybody has any answers. Thanks.

1 Answer 1

5

Assuming you have a function like below in Javascript

function getTheName(id)
{
//Some stuff
return name;
}

You can call , pass parameters and get back a value from it like below

NSString *ID = @"THE_ID";
NSString *theJSMethod = [NSString stringWithFormat:@"getTheName('%@')", ID ];
NSString *returnedValueFromJSMethod = [yourWebViewInstance stringByEvaluatingJavaScriptFromString:theJSMethod];
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.