1

I have a PhoneGap application that loads web content from a web server which requires authentication. I have a solution to post user credentials in the HTTP headers over HTTPS when I launch the web content in the InAppBrowser, once user is accessing content in the InAppBrowser, they can navigate among several server side web pages. My problem is that I need to be able to trap for HTTP Status errors (401, 403, etc) in the event that the user needs to re-authenticate. If I can capture these errors, I can make an Ajax call to re-authenticate the user. Any ideas on how to detect HTTP errors from the InAppBrowser?

MNDaveC
  • 141
  • 7

1 Answers1

0

You can add an event listiner to the inappbrowser method to detect errors:

.addEventListener('loaderror', function(event) { alert('error: ' + event.message); });

You will have to do some testing to see what the actual event.message returns and probably parse it to take action on different event codes but the above will work. See this for full documentation.

*Note, this will only work for initial load I believe, not subsequent navigation once it has loaded the initial page.

Dom
  • 2,569
  • 1
  • 18
  • 28