Support Forum Softcomplex logo
About Us  | Services  | Download  | Order  | Support  | |
| Search | Today's Posts | Stats | Board Rules | Not logged in [ Login | Register ]
go to bottom
Last active: Never

Printable Version | Subscribe | Add to Favourites   Post new thread
Author: Subject: debugging javascript

Posts: 2049
Registered: 6/17/2002
Location: US, CO
Member Is Offline
posted on 6/27/2006 at 10:54 AM Reply With Quote
debugging javascript

There is the variety of debugging tools for JavaScript code, but very few of them are free and they are mostly needed for programming. To debug configuration errors you can use what you already have:

- JavaScript Error Reports
- Web Servera??s Log File
- Alert boxes

1. JavaScript Error Reports
JavaScript error messages are the first sign of something going wrong with script configuration. It is always good idea to keep them turned on in browsera??s configuration while developing web sites.

1.1. JavaScript Error Reporting in Internet Explorer
To enable error reporting in Internet Explorer make sure a??Disable script debugginga?? checkbox is not checked at Tools->Internet Options->Advanced->Browsing. If a??Display a notification about every script errora?? option is not checked you should look for error icon in the status bar of the browser while testing the page. Note that error message are displayed separately and you need to use a??Preva?? and a??Nexta?? buttons to see them all.

1.2. JavaScript Error Reporting in Netscape
To display JavaScript errors in Netscape browser select a??JavaScript consolea?? item under Tools->Web Development in the menu or type a??javascript:a?? (without quotes) in browsera??s address bar and press Enter.

1.3. JavaScript Error Reporting in Other Browsers
The most of the webmasters have both Internet Explorer and Netscape browsers installed. JavaScript error massages in all browsers look pretty the same so there is no advantage in using some other browsers for debugging. To enable and access error messages in browser not listed here consult its user manual.

2. Web Servera??s Log File
Web servera??s log is the text file where web server registers all the requests it receives. Some script configuration problems are caused by invalid references to the files (linked JavaScript files, images, style sheets etc.). Those problems are clearly indicated in the web servera??s log file by status 404 (Resource not found error), the message also displays what invalid URL the script tried to access:

Code: - - [25/Jun/2004:10:31:46 -0600] "GET /img/pixel.gif HTTP/1.1" 404 291

Contact your server administrator or web hosting provider for instructions how to access web servera??s log files. Log files are not available if development environment doesna??t use web server.

3. View Source
When debugging client side code it is important to see actual code that browser receives especially when client side code is generated dynamically by server side script. Use browsera??s View->Source feature to inspect client side HTML code. To view code inside linked configuration files (.JS, .CSS etc) put the URL of the file in address bar of the browser, press Enter, save file to disk and then use text editor to see the content. Some browsers allow to view JavaScript code and Style Sheets without saving files to disk. If View->Source feature doesna??t seem to work in Internet Explorer then remove temporary files Tools->Internet Options->General->Temporary Internet Files->Delete Files.

4. Alert Boxes
Alert boxes are pop-up messages initiated by method calls in JavaScript code. They can be used to verify if JavaScript file is properly linked to main HTML document, what value is assigned to some variable etc. For example add


to linked JavaScript file and youa??ll see message box with word a??testinga?? while page loads if file is linked correctly.
View User's Profile View All Posts By User U2U Member
Post new thread

Related Links:

Go To Top

Powered by XMB 1.9.1 Nexus
Developed By Aventure Media & The XMB Group © 2002-2004