What is weinre?If we do Cordova (PHONEGAP) or other hybird applications, when using the native function (similar to native request data or page switch), there is no way to debug the page in the PC Chrome browser, once the page shows a problem on the phone, we are more difficult to find the reason, Sometimes you can only guess or alert something. Using the Weinre tool, Weinre is intended to be a web Inspector remote, which can be used to debug page elements, styles, and JS on a PC via a remote debugging tool.the principle of weinrethree-terminal meaning:Client: local webinspector, remote debugging client. Server (Agent): A local httpserver that establishes communication with the client for the target page. Target page: The page being debugged, the page has been embedded in Weinre's remote JS. (above pictures and explanations are transferred from other articles)Debugging Process:The client posts the instruction (Request DOM, executes JS) to the proxy server, the target page is timed (approximately 5s) from the server-side get instruction, then the result is post back to the server, and the final client is timed to get the result from the server. PS: Since the Weinre client is based on Web Inspector Development, and the Web Inspector is only compatible with the WebKit core browser, it is only possible to open the Chrome/safari client for debugging in the Weinre browser.weinre InstallationInstalling NodejsWeinre is based on Nodejs, so first install Nodejs, address Http://blog.nodejs.org/2013/07/25/node-v0-10-15-stable/PS: Use v0-10-15 version of Nodejs, or weinre can't install it.Installing Weinrecommand line execution
Npm-g Install Weinre
This is where the installation was successful.Weinre Run1. Command line type
Httpport the port that is running for the debug server, default 8080;boundhost the IP address or domain name of the debug server binding, default localhost. 2. Using the WebKit browser (because Weinre is designed more WebKit-based browsers, it is recommended to use Chrome/safari) to access the WEINRE server: http://localhost:8081 3. Click to open the Debug panel: http://localhost:8081/client/#anonymous 4. Get the IP address of the server, for example: 192.168.1.101, add the following JS to the page you want to debug.
<src= "http://192.168.1.101:8081/target/target-script-min.js#anonymous" ></script>
5. On the mobile device to access this page, that is, the client click Targets to see the structure of the page, or to execute JS.
Weinre Debugging the mobile side page