GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Monday, January 10, 2011

Debugging Javascript Code

The usual technique is using alert to check variable, function return or a line broken.
But there's a more advance technique for do debug error - use try catch block.
try{
    varq;
}catch(err){
    alert(err);
}
ouput: ReferenceError: varq is not defined

type for other output are:
alert();
output:
    [Exception... "Not enough arguments 
    [nsIDOMWindowInternal.alert]"  nsresult: "0x80570001
    (NS_ERROR_XPC_NOT_ENOUGH_ARGS)"  location: "JS frame ::
    http://htmledit.squarefree.com/ :: 
    :: line 5"  data: no]

output:
    TypeError: Doc.getElementsByTagName("lang")[i] is undefined
          
                

Share/Bookmark

No comments:

Post a Comment