JavaScript
  Home arrow JavaScript arrow Page 4 - Debugging in Javascript
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Debugging in Javascript
By: Chris Root
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 21
    2005-02-16

    Table of Contents:
  • Debugging in Javascript
  • The Hard Way
  • Using Comments
  • Are We There Yet?
  • Make a Log Window

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Debugging in Javascript - Are We There Yet?


    (Page 4 of 5 )

    Okay now, let's get rid of the comment characters and the alert altogether. What? Still not working? There is one more problem. We have a string to which we are setting our text field value that uses a mix of single and double quotes. This is bad.

    <script language="Javascript">
    //The Script
    function doIt(fName)
    {
       var fObj = document.getElementById(fName);
       if(fObj.value == "")
       {
          fObj.value = 'You're really pushing my buttons!";
       }
    }

    Change the single quote to a double one and then try again. It should work just fine. Let's hope that you won't have that many errors in your script, but by walking through it we got to the bottom of errors that otherwise might have taken a long time to find.

    One Problem with Alerts

    Some browsers (Firefox on OS X for instance) do not allow you to select and copy text from an alert box. This can be useful if a script you are writing generates HTML using DOM methods. This markup will not be visible using the "view source" browser feature. If you display the innerHTML property of a tag in an alert dialog, select it, copy it and paste it into a blank document, you can work with it to fix any problems or try different styles without running the script that generated it each time. If you can't select the text in the alert dialog, then you need another solution.

    More JavaScript Articles
    More By Chris Root


       · Welcome everyone. Thank you for reading the article.
       · Good article. The popup window with updating values is a great way to watch the...
       · log4javascript (http://www.timdown.co.uk/log4javascript) has excellent pop-up...
       · I was having problems debugging a problem, that only happened on a live site - the...
       · Think I forgot to supply the link... doh! ;-)Here it is:...
       · You say one should name the file for the log window "dialog.html", but you're using...
     

    JAVASCRIPT ARTICLES

    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT