Debugging idea

    Date: 10/12/07 (Javascript Community)    Keywords: html, java

    I got tired of clicking OK on a dozen alert statements when I was trying to debug some troublesome javascript, so I came up with this simple alternative:

    function dump(descr,value) {
        // This function dumps javascript data to the page, if a place for it exists.
        if (document.getElementById("dump")) 
            document.getElementById("dump").innerHTML+=descr+": "+value+"
    ";
    }

    So long as you have an element with an ID of "dump", e.g.

    You can view the values of troublesome variables on the page like so:
    dump("troublesomeVar",troublesomeVar);

    Source: http://community.livejournal.com/javascript/142968.html

« Scimons #1 Javascript No No. || Ok...so weird question for... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home