Use Weinre to debug your phone page

Source: Internet
Author: User

Weinre ( We b inch Spector Re Mote), is a remote debugging tool. Features like Firebug and Chrome debugger, can help us to change the page elements, styles, debugging JS and so on.

Working principle
Weinre is made up of three parts1. Debug ServerThe core component, which runs on the server side, is responsible for communicating with the other two parts.2.debug ClientWebKit Nuclear Browser,AndDebug server communication. Display the Debug interface, allowing you to modify the DOM, view network information, etc. 3. Debug target. The page you want to debug. You need to embed a small section of JS in the page. It communicates with the debug server through the XHR mode , sending and receiving debug information.


Installation

installation is very convenient. In the case of Linux machines, first you need to have node. js. Run laternpm g-g intall weinrecan be.


Run1. Start the debug server sideexecute under command line
Weinre--httpport 8081--boundhost 10.136.30.144
It means listening to the 10.136.30.144 8081 port.
2. Start the Debug clientAccessing http://10.136.30.144:8081/on a PC browser will see a page similar to the following

lists the documents for Weinre and the URLs for debugging. Click http://10.136.30.144:8081/client/#anonymous to see the following debugging interface.

tell us that there is currently no targets access. The client and server side information are also listed.
3. Start target
In the need to debug the page need to introduce a section of JS
<script src= "Http://10.136.30.144:8081/target/target-script-min.js#anonymous" ></script>
Of course, if you want to debug a lot of pages, it is inconvenient to insert the above code directly on each page. Browser "Bookmark" Way to save a section of JS, dynamic way to insert script
JavaScript: (function (e) {e.setattribute ("src", "http://10.136.30.144:8081/target/target-script-min.js#anonymous" );d Ocument.getelementsbytagname ("body") [0].appendchild (e);}) (Document.createelement ("script")); void (0);
The above two methods are described in detail in the documentation page mentioned in step 2. Suppose we want to debug a page that runs on 10.136.30.144:3927After introducing JS in the page, open the page to be debugged with the mobile browser http://10.136.30.144:3927/new
4. Start DebuggingAfter the Mobile Access page, we go back to the debug interface described in step 2. Found at this time, targets a more, that is, we use the phone in step 3 to open the page to be debugged.Click on the target to debug with the familiar debug interface.

Other Instructions
1. Continuous access to multiple pages with the mobile phone, these pages are listed in targets, select one, you can debug. 2. Click Remote in the Debug page to cut back to the targets list from the Debug page. 3. Although the document says that the client is to be used on a basic webkit-core browser (Google Chrome,Apple Safari,Other recent-ish webkit-based browsers), but the pro-test Firefox seems to be able to play around. 4. And the most important. Server and target and client must be interoperable so that they can be debugged.
Some limitations1. Elements section, you can view the DOM and modify the style. However, you cannot edit dom2 directly. Resource section, Localstorage can be viewed, but the cookie is not visible. 3. The network section can only see requests that are loaded asynchronously. (Maybe I have a problem with the method?) 4. Cosole section, you can see the console log, run JS. But can not be like Firebug to quote JS error, but also can not add breakpoint debugging. Anyway, even so, has provided some degree of convenience for our debugging. It's better to have a better touch than to close your eyes.especially if you want to debug your iphone page and have no Mac book on your hand, try weinre. What? You don't even have an iphone!? God bless you~

Use Weinre to debug your phone page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.