1

A webpage users of my app are trying to load has this link:

<a href="javascript:DoSubmitScr('1B'); SetTextOption('Detailed');" id="btn_14" class="Button1" style="position:relative;width:190px;">

And it tries to call this javascript block:

function DoSubmitScr(scrval)
{  
  GlobalHelpUrl = HelpUrl;
  document.getElementById("hScreen").name = "SCR";
  document.getElementById("hScreen").value = scrval;

  if (scrval.toUpperCase() == "1B" ) document.getElementById("main_iframe").scrolling = "no";

  document.forms[0].target = "_parent"; 
  document.forms[0].method = "post";      
  document.forms[0].action = "/wtouch/perinfo.exe/oper";
  doSubmit();
}

Now I try to do this javascript:

[webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('btn_14').click();"];

But it doesn't work, nor when I try to do it like this:

[webView stringByEvaluatingJavaScriptFromString:@"DoSubmitScr('1B');"];

Any ideas on how to invoke this javascript method?

Ron

Ron
  • 1,047
  • 13
  • 18
  • [This answer](http://stackoverflow.com/questions/17117713/passing-data-to-and-from-an-embedded-uiwebview/17118065#17118065) might help you – Alladinian Jun 17 '13 at 13:36
  • Thanks, but the Javascript is called in webViewDidFinishLoad when webView.isLoading == NO so this shouldn't be the problem. Any other ideas? – Ron Jun 17 '13 at 15:30

1 Answers1

0

Okay, I found the problem.

webViewDidFinishLoad started with:

if (webView.isLoading == YES) return;

So no code was executed before the webpage was fully loaded.

The page that was called with the javascript above for some reason never completes its loading so the next functions never get called...

When I remove the .isLoading statement everything works fine!

Ron
  • 1,047
  • 13
  • 18