0

My objective-c code looks like this:

NSString *test = [NSString stringWithFormat: @"testFunction(%@)", details.name];

NSString *userName = [webView stringByEvaluatingJavaScriptFromString:test];
NSLog(@"Web response: %@",test);

This prints out testFunction(the string of details.name here).

My javascript looks like this:

<script type="text/javascript">document.write(title);</script>

var title;

function testFunction(var) {
    title = var;
}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Lewis
  • 159
  • 10

1 Answers1

0

In the JS you closed the script tag in the first line leaving out the function

your JS should look like this

    <script type="text/javascript">document.write(title);

var title;

function testFunction(var) {
    title = var;
}
</script>
cromanelli
  • 576
  • 1
  • 5
  • 21