Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug JavaScript code with mobile browsers

I know about firebug and the developer tools for the major modern desktop browsers, but I can't find any way of debugging JavaScript code on mobile browsers.

What are some high level techniques I can use to debug code on mobile browsers?

like image 577
chnxster Avatar asked May 10 '11 00:05

chnxster


People also ask

How do I debug JavaScript code?

In the debugger window, you can set breakpoints in the JavaScript code. At each breakpoint, JavaScript will stop executing, and let you examine JavaScript values. After examining values, you can resume the execution of code (typically with a play button).


3 Answers

Android devices can be put into developer mode by going through settings>Phone status then tapping on "Build number" 7 times. This allows you to do a bunch of things (see step 5) including USB debugging. (Some devices might have Build number under Software Info)

To activate USB debugging, look in Settings for the newly appeared "{ } Developer Options", open this and switch on USB debugging. Connect your device using a direct USB connection.

In Chrome on your desktop, in the usual developer tools panel used for debugging, look in the menu for more tools>remote devices. With Discover USB devices selected, you should now see your mobile device on the side.

Select it to see a list of all the chrome tabs you have open and the ability to enter URLs directly.

Selecting one of the links will open up a new window with a mirror of your device screen on the left and all the familiar chrome debug tools on the right. You can still control your device directly or use the mouse on the mirrored screen. It even rotates.

full details on remote debugging from google and how to enable developer mode (link as above) from askvg.com

like image 126
franki Avatar answered Oct 13 '22 00:10

franki


Android provides a tool set for these purposes: https://developers.google.com/web/tools/chrome-devtools/remote-debugging/?utm_source=dcc&utm_medium=redirect&utm_campaign=2016q3

Apple does it a similar way: https://developer.apple.com/safari/tools/

Tutorial: https://css-tricks.com/using-chrome-devtools-to-debug-javascript-in-any-browser-with-ghostlab-2/

like image 43
Hermann Schwarz Avatar answered Oct 13 '22 00:10

Hermann Schwarz


You can debug on Safari Mobile with any iPhone/iPad. In Developer menu you can find your device and you can then debug your code with inspector.

If you have an Android Device instead, you can debug on Chrome Desktop (remember to active the debug mode) with chrome://inspect

like image 29
Salvatore Cozzubo Avatar answered Oct 13 '22 01:10

Salvatore Cozzubo