views:

38

answers:

2

I'm running into a very annoying issue developing javascript for a UIWebView in an iPhone application. If there is an error in the javascript, it silently fails and halts execution of the function it was running. And some errors do not happen in a desktop browser, so all appears fine. I then run it on an iPhone and get a massive failure as the function craps out half way through, and no idea why. I then slowly and methodically comment out various lines of code until no catastrophic failures happen, in order to pinpoint the offending line of code.

This sucks.

So is there any way at all to get a UIWebView to log or report in anyway javascript errors? They are obviously happening, I just don't know why or how, and it's making my life hard.

A: 

Have you tried in the iOS Safari Settings to turn on the debug console? Just go to settings ->Safari -> Developer and turn on debug console. The UIWebView should be at the very least extremely similar as to whats in the iOS Safari App. Might get you started.

Rudiger
This has worked in a pinch, but being completely outside my app makes it not really work like we need it to.
Squeegy
A: 

Are you implementing the UIWebView's didFailLoadWithError delegate?

It might give you an error code.

hotpaw2
Nope, it doesn't. These errors occur during use of the page, and not on page load itself. And even then, it still doesn't trigger this delegate method.
Squeegy