Ios webview calling javascript function wont work -
my objective-c code looks 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 this:
<script type="text/javascript">document.write(title);</script> var title; function testfunction(var) { title = var; }
in js closed script tag in first line leaving out function
your js should
<script type="text/javascript">document.write(title); var title; function testfunction(var) { title = var; } </script>
Comments
Post a Comment