0

I am loading an html file to uiWebView and getting variables that were set previously on a div using:

 NSString *body = [self.webView stringByEvaluatingJavaScriptFromString:
                          @"document.getElementById('var').innerHTML"];

but I need now the reverse process, set variable to html file using javascript. Html javascript code will wait then until I send a var. Something like following pseudo code,

 [self.webView stringSetJavaScriptFromString:
           @"document.setElementById('var').innerHTML", myStringVar];

Thank you.

1 Answer 1

1

Have you already tried

[self.webView stringByEvaluatingJavaScriptFromString:
      [NSString stringWithFormat:@"document.getElementById('var').innerHTML = '%@';",myStringVar]];

?

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.