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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -