Is there a way to view the source HTML in the Android web browser?
migrated from stackoverflow.com Jan 21 '11 at 22:36
|
You can use Javascript's
|
|||||||||||
|
|
In Firefox or Chrome on Android it's possible to view source by prefixing the URL in the address bar with " |
||||
|
|
|
If you are using a Opera browser type this in your address bar, make sure you erase the http and other stuff, then type:
in the address of the page which you opened. |
||||
|
|
|
Another tool that is useful for viewing source AND modifying them live, in Firebug/Web Inspector-like manner, is the weinre remote debugger. |
|||
|
|
|
If this is for debugging (from your comment it looks like it is) something even better is installing a user agent switcher extension for Firefox or Chrome on your desktop. Change the user agent to Android and you get the mobile version of the site, but with all the source and debugging tools you're used to. |
|||
|
|
|
you can capture the source to your shell or to a text file if you're using an emulator, which is very handy for development. To do this you'll need to install Android Developer Tools, which comes with adb. Fire up your emulator then from your OS's shell run the command:
This will output anything from the browser app on your emulator and suppress any other log messages. From there any javascript console.log commands will be captured by adb and output for you to view. So, if you're using JQuery, you can add this to your page and it'll output the whole page html to the log:
This will output everything within your html tag on the page to the log. You can capture the output of your log (using BASH, at least, I can't speak to other shells) with:
now, any output from the log gets dumped into your log.txt file. This is really handy for a whole page's worth of HTML, as you can then search through it as you would any other text doc. If you want to grab a specific bit of the page rather than the whole thing, you can specify that part of the page rather than the html tag in your JQuery, so if you need to look at a single div that has a class/id associated with it (for this example, it has a class named 'inspect-me'), you can change your JQuery to:
|
||||
|
|
Look for an app called "View Web Source" in the market and install it. Then when browsing, open your menu and tap "share", in the list that pops up choose View Web Source. Just in case you don't see GAThrawn's comment below, here is a market link: https://market.android.com/details?id=com.jamesob.vwsource |
|||||||
|
