Debugging JavaScript errors on iOS, android and other mobile devices
Just ran into a JavaScript bug on an iPhone that didn't occur on my regular browsers. Usually I will load up Safari but everything was fine there as well.
So I've discovered this neat website: http://jsconsole.com/
basically you start with the command :listen and it starts a remote debugging session. You will get a session ID which you can use by inserting the following script into your page
<script src="http://jsconsole.com/remote.js?SESSION-ID-GOES-HERE"></script>
When you visit your page now with the device experiencing the bug, you can access the console log from your development browser.
Now with some good ol' trys and catches you can start locating the source of the error.
try{
//execution of a chunk of code
}catch(e){
console.log('caught error in a chunk of code');
console.error(e);
}
And as extra bonus, you can run JavaScript code as commands through the http://jsconsole.com/ that will affect the device running the session. Mess about with jQuery and other fun JavaScript.
Here's a short intro by Remy Sharp http://www.youtube.com/watch?v=Y219Ziuipvc
Written by Mark Vaughn
Related protips
1 Response
More advanced but not less comprehensible alternatives:
External Chrome Dev Tools: http://debug.phonegap.com/
External Firebug: http://getfirebug.com/firebuglite