javascript - Execute stringByEvaluatingJavaScriptFromString before click event -


i using uiwebview in iphone , loaded 1 html page resources.

following html page code:

<html> <head> <title></title> <script language="javascript"> function callme(id) {        var input = 'input'+id;     document.getelementbyid(input).value = document.getelementbyid('code').value; } </script> </head> <body>  <input type=hidden id='code' name='code'> <a href="#" id="click1" name="click1" onclick='callme(1);'>click1</a> <input type="text" id="input1" name="input1"> </br> <a href="#" id="click2" name="click2" onclick='callme(2);'>click2</a> <input type=text id="input2" name="input2"> </br> <a href="#" id="click3" name="click3" onclick='callme(3);'>click3</a> <input type=text id=input3 name=input3>  </body> </html> 

i have inject javascript on page using following code:

[webview stringbyevaluatingjavascriptfromstring:@"var field1 = document.getelementbyid('code'); field1.value='code010203';"]; 

what want when user click on link first injected script should run , onclick event's function(callme(1) or 2 or 3) link(click1,click2 or click3) should execute.

function callme(id) {        injectedcode();     var input = 'input'+id;     document.getelementbyid(input).value = document.getelementbyid('code').value; } 

where injected code is:

[webview stringbyevaluatingjavascriptfromstring:@"var field1; function injectedcode() {field1 = document.getelementbyid('code'); field1.value='code010203';}"]; 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -