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?
Asked
Active
Viewed 1,125 times
1
-
Adding some code you already have increases answers – Mark Veenstra Sep 24 '13 at 13:56
1 Answers
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
-
-
Hi,How to handle 503 errors, its not coming inside 'loaderror' event handler. – love-for-coding Jun 09 '18 at 13:14
-
@Dom loaderror doesn't captures HTTP error codes. you might need to try it out – minigeek Dec 12 '19 at 06:14