seeing javascript errors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepjain
    Contributor
    • Jul 2007
    • 563

    seeing javascript errors

    Hii ..i am a lamp professional!! i use javascript for validation purposes! but sometimes javascript stops working bcos of errors!!and i find it difficult to find those errors! is there any log for javascript errors??
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Pradeepjain,
    Ya, there are two ways of finding errors in your codes. The first way is writing your js code inside a try catch block and the other is to test the codes with the alerts one line after the other. These are the possible two ways through which u can find or debug an error in the js.

    Try Catch Block

    Code:
    try{
    // your JS Code...
    // your JS Code...
    }
    catch(e)
    {
       alert(e.message);
    }

    Alerts

    Code:
    js line no 1
    alert("1");
    js line no 2
    alert("2");
    js line no 3
    alert("3");
    js line no 4
    alert("4");
    Thanks and Regards
    Ramanan Kalirajan
    Last edited by RamananKalirajan; Aug 28 '09, 07:07 AM. Reason: Added the example codes

    Comment

    • oranoos3000
      New Member
      • Jan 2009
      • 107

      #3
      showing error in separate window for debugging

      hi
      you can using this code for showing your error in separate window and the end of debuging your scripts you can erase this code from the other code
      on the input of script tag
      Code:
      <script type="text/javascript">
      onerror=showErr;
      function showErr(errMsg,location,lineNum)
      {
      ErrWin=window.open('','new window',"width=100, height=100");
      ErrWin.document.write('message of error '+errMsg+'<br />place of error '+location+'number of line that have error'+lineNum);
      ErrWin.document.close();
      }
      </script>
      and so if your browser is firefox you can see your error
      by clicking menu tools->javascript consol
      be success
      Last edited by gits; Sep 1 '09, 11:17 AM. Reason: added code tags

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        another excellent extension for Firefox is Firebug ... have a look here ... i cannot live without it :) ... you could debug, inspect, test nearly everything of a webpage with it ...

        kind regards

        Comment

        • ghmcadams
          New Member
          • Feb 2010
          • 1

          #5
          .Net method of logging JavaScript Errors

          I have just released code to help log JavaScript errors by sending error information to the server. If you want to use ASP.Net, you can take a look at the control here -

          Comment

          Working...