Overwriting JS error function
In cases where access to a browser console isn’t easily accessible to debug your javascript code, like when build Phonegap apps, you can change the standard javascript error function to turn the error into an alert box using the following code.
window.onerror = function(msg, url, linenumber) { alert('Error message: '+msg+'\nURL: '+url+'\nLine Number:'+linenumber);return true; }