JS Debug-Navigate to the file location where the function is located

Source: Internet
Author: User

Original: http://www.cnblogs.com/52cik/p/js-console-show-source.html

In the console, enter the function name you want to find, such as Votepost and then enter:

The source code of the function is bold, and there is a link in the lower right corner blog-common.js?v=we8o1xrgctu07qvvwyqerqd7aa8fdjp_dgoe-crat3k1:1 What does this mean?
Behind the V=WE8O1XRGCTU07QVVWYQERQD7AA8FDJP_DGOE-CRAT3K1 directly ignored this is the version number, which prevents caching.
Blog-common.js:1
Blog-common.js is the JS file where the function resides, and 1 is the line number where the code is located.

Directly Click this link, you can jump to the Sources panel, this is the source panel, debugging the most important feature, will be introduced slowly.

But all the code is in one line, how do we look at it? 4,946 characters, fully indented on one line ...
Chrome provides us with a code formatting feature that can be formatted by clicking on the Pretty Print button below.

After the format is finished is very beautiful code, as to see do not understand, that is another matter.
Some can not understand the code is Uglifyjs,google ' s closure such as the tools compiled, such as jquery.min.js files.
If the format is enough to find the location of the function, do not worry, I am in, panic what? Go back to the console panel just now.


You are delighted to find that blog-common.js?v=we8o1xrgctu07qvvwyqerqd7aa8fdjp_dgoe-crat3k1:91
Line number becomes 91, now click this link, you can jump to the corresponding format after the location, is not super convenient.

Today's content is almost these, in fact, there are very few direct global functions for you to debug, because now jQuery popular, all kinds of click, on the event of binding, resulting in a very cumbersome source location.
Fortunately, I wrote an article, a more detailed analysis of the problem, please refer to the "JQuery Incident source Location Problem"

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.