Pages

Debug Javascript on Android

Tuesday, October 1, 2013

Front end web developers have quiet a few options to debug javascript errors, and nowadays there is a burst of devices on which development in javascript has become crucial leaving the developer baffled with less debugging options.


So lets have a look at what are the possibilities and a solution.
  • Alert your code/errors, the simplest of ways.
  • Get more info by console.log()

Alert your code/errors
Its the most practical way to get to your errors in javascript and its perfectly fine on the desktop for light debugging.
But if you use alert on mobile devices, especially for gesture events, you will end up getting a continuous stream of alerts even with the slightest of gesture and hinder your development process.


console.log()
console.log proves useful by logging your debug statements to the browser's log, without hindering the flow of your script as in alert.


Enable console on android devices
To enable console window on android, open a new tab in the android browser, type "about:debug" without the quotes tap GO. It may feel nothing happens, but console window has been enabled.
Now return to your application window, add console.log() in your scripts, let the javascript run and you will find a "show console" option below the page tab, ready with your console statements.



No comments:

Post a Comment

 

Tags

Blogroll

Archives