There are many ways
Debug JavaScript. We first discuss from the code itself:
Inserting Alert into code is the most common way, you can prompt the value of the variable, type, function parameters, object properties. If you use branch code to support your different things, you can use Confirm to enforce the specified branch function. If you want to be able to cut the paste, you can use the Prompt. To get a more detailed error report, you can use the Window.onerror or TRY..catch statement. This will allow the code to run directly, and will not be suspended due to an error, thereby reporting all errors after the code is executed. Some errors enter our code in our unknown, and it is difficult to find. We must strictly abide by the code agreement, such as explicitly ending the statement instead of semicolon insertion; always using the curne brackets to enclose the control structure like IF, if..else, switch, while, do..while, For, for..in statement; use parentheses to represent priority rather than the operator itself; use unified detailed naming rules; use unified code indent rules to make the source code more easy to read; use explicit types Disclaimer to avoid automatic type or in a way to achieve the same effect; some simple ways (especially IE) for different browsers, try to use code that meets standard syntax .... Reduce these difficulty errors in the above manner. You can run the code via javascript / lint.html "target = _blank> JS Lint, it can detect certain potential errors. The above is what we do through the code itself. Let's take a look at the code in the browser
Test your development of the angle you develop with multiple different types of browsers. In a Windows environment, at least IE6W, OP7, and Moz are used. In the MAC machine, you should use at least SAF, OP7, IE5M, and Moz. If there is a code that does not work in one or more browsers, you'll see if you can solve some different code. If you can't still do it, you have to make a branch execution code according to the different browsers. Error reports must be enabled in IE. If Windows is used, Microsoft Script Debugger can be used. If you need to track an error, you can use the Debugger keyword control angle in the angle to execute in debug mode. It is recommended to use IE testing, debugging with OP7 or Moz. In OP7, be sure to enable JavaScript error report in JavaScript console. OP7's JavaScript Console is much better than IE error reports. It has a better code trace function, easier to see the source call source. And you can report the correct error line, different from the IEW. There are many tools in Moz. You can use Mozilla JavaScript Console, which can report errors and warnings and allow simple angle assignments. You can enable a harsh warning to prompt a lot of potential error locations. You can display the Dom Inspector to display the Document tree, Stylesheets tree, Computes, and JavaScript objects. You can get a higher JavaScript debugging tool with Venkman (Mozilla JavaScript Debugger). Available with Ian Hickson's JavaScript Evaluation Sidebar or Jesse Ruderman's JavaScript Environment, View Scripts Bookmarklet, JavaScript shell, or View Variables Bookmarklet or ViewScripts Bookmarklet. In KonQ, more power is more, using some source code skills. In SAF, you need to enable Hide Debug Menu, which doesn't have to display unambiguous error messages in the system console, use the show Dom Tree feature more useful. If you enable the display debug menu, Safari does not run, use the following command in the terminal: code:
Defaults Write Com.apple.safari Includedebugmenu 1