How to find unknown javascript errors: first run the javascript page; then click the browser's settings icon and find "Developer Tools" in "More Tools"; finally open the tool and refresh the page. You see error messages on the console.
The operating environment of this article: windows7 system, Google87.0&&javascript1.8.5 version, Dell G3 computer.
How to check for unknown JavaScript errors?
Write a test code first. The script is very simple. It just displays the results of a and b on the page.
Run the page, and you can see that the correct results are output on the page.
But if we make a mistake, write the code of a b in a bb, as shown in the figure
Run page , the page does not display correct data, but no error is reported, and it does not affect the operation of the page.
#In order to find this potential error, we can use the browser's developer tools.
Click the browser's settings icon, and then find 'Developer Tools' (Chrome browser) in 'More Tools'
(Press the shortcut key F12 or other shortcut keys, different browsing The shortcut keys are different for different systems)
After opening the tool, refresh the page, and you can see a red error on the console, which prompts us that the variable bb is not defined. .
You can also click to activate this button in the debugging page (source), which will enter the interrupt when an exception is encountered.
After activation, refresh the page, you can see that the interruption is immediately entered, which makes it easier for us to find what went wrong.
[Related recommendations: javascript advanced tutorial]
The above is the detailed content of How to check for unknown JavaScript errors. For more information, please follow other related articles on the PHP Chinese website!