7.2.4 Client Script Error
So far, we have learned about the errors from the ASP. However, ASP is often used to create Web pages that contain client-side scripting. If the <SCRIPT> element that contains the client code is not set to the runat= "server" attribute, the ASP will not consider the server and transfer the Web page information to the client without change.
Therefore, if an ASP page is open and a browser error dialog box is displayed, you should not look for errors in the ASP program code on the server side. The browser does not see the ASP program code, so do not recognize any errors, if a dialog box appears on the client, then there must be an error in the client code.
1. Syntax error
If the client-side program code in the Web page has syntax errors, the browser will have a corresponding error when the script is downloaded to the client. The Web page stops executing, although the contents of the Web page can still be loaded normally (unless they are dynamically loaded by these client script code). The user will see a dialog box containing the error details, or a status bar message indicating that the page contains an error.
Modern browsers tend to hide the details of Web script errors and only display a small error icon on the status bar. In IE 4.0 and IE 5.0, the normal error dialog can be activated by setting the Advanced page of the Internet Options dialog box, as shown in Figure 7-14:
Figure 7-14 Advanced Page Setup screen
Client errors in the processing script code are similar to those on the server side, and are usually easier to download because you can often double-click the Web page directly from the server directory. The only difference is that some server interactions are done by client script, such as data binding with RDS or dynamic loading, without the need to get web pages to see the results in the browser.
2. Run time or semantic error
In client script, you can often encounter syntax errors, and you will often experience run-time or semantic errors. In fact, on the client side, this phenomenon is very common. Because the client cannot control the script's environment like the server side, it is not sure what the user is running on their machine, and in fact the server can only get a general picture from some components such as browser capabilities.
Therefore, scripting programs that use client objects or special versions of scripting languages and properties are likely to not work correctly. However, handling client errors and handling server-side errors is almost the same.
3. Client program code created on the server
A special exception to the "Client dialog for ASP error pages" rule (where there is an error) when the error occurs is to use ASP program code to dynamically create client program code on the server. For example, you might want to evaluate in an ASP, and then pass the data to the script code that runs on the client, perhaps the easiest way is to insert the data as a variable into the script code:
<%
' Get the ' name of my server from the ServerVariables collection
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