Javascript-if a blank page is opened, how do you locate the problem? If it is not a network or server problem, it is a front-end problem. how should we locate it?

Source: Internet
Author: User
Tags blank page
I saw an interview question just now. I don't know how to answer it. I don't know what you think. Thank you very much. I saw an interview question just now. I don't know how to answer it. I don't know what you think. Thank you very much.

Reply content:

I saw an interview question just now. I don't know how to answer it. I don't know what you think. Thank you very much.

Check the status code returned by the page in the browser developer tool. if it is a 500 series, it is a server error. you can view the error log of the web server to find the error. if it is 200, the returned result is successful, you can check whether there is any error message under the console to determine if there is a js problem. you can also check the page source code to see if there is any content. of course, this is unlikely to detect the problem.

1. Frontend Analysis: open the chrome dev tool, record the http [s] proccess, then you will get the http status code;
2. Backend Analysis: grep nginx error log or access log, grep the unexpected http request, then get it.

Js blocking?
If the external js is inAnd the execution time is very long. in this case, the page should be blank. Until loading and execution are completeTo display the page, that is.

Check the resource loading status to determine whether it is a network or server problem. Check whether js reports errors and gets stuck in page loading. View the page source code.

If it is a front-end problem, there are many types of errors, such as script loading errors and js code problems. If the problem is caused by resource loading, the browser developer tools should be able to detect the problem and take the right medicine. There are many solutions to problems in the code. try... catch is a simple and common method. That's all I know.

I have my own solution, but I don't know if it is suitable for an interview. if it is unreasonable, please forgive me.

  1. First of all, if there was a page when I wrote it myself, and after I wrote some code, I refresh the browser again and then I will copy the code I just wrote and the entire segment, then delete the original page. If yes, check the new code and put it in the main code.

  2. Second, if you write a lot of code and do not know what went wrong, you should first open the page and check whether the tag is complete, whether the head link is correct, whether the js order is correct, and whether there is a conflict.

  3. When I write JS, I am used to using ff and Google browsers. if something goes wrong, F12 checks whether the console reports an error and uses the console more. log (). alert () for debugging.

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.