Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    wac
    wac is offline
    Regular Coder wac's Avatar
    Join Date
    Sep 2002
    Location
    Cary, North Carolina, USA
    Posts
    359
    Thanks
    2
    Thanked 0 Times in 0 Posts

    how do people debug vague javascript errors (Line 1, Char 5, Error: Syntax error)

    Appologies for the vague title but I wasn't sure what to really put there. IE gave me this wonderful error message when I clicked on an element with an onclick...

    Line: 1
    Char: 5
    Error: Syntax error
    code: 0
    URL: ...blah... (a struts action url)...

    of course line 1 is the <html> tag line so that's not where the error really is. The wierd thing is that the function that is suppose to occur when one clicks on the element actually works! so what the heck is the popup error box trying to tell me?????
    Wayne Christian

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I try running it in the Mozilla or Netscape 7 browsers as their JavaScript consoles give better messages.

  • #3
    wac
    wac is offline
    Regular Coder wac's Avatar
    Join Date
    Sep 2002
    Location
    Cary, North Carolina, USA
    Posts
    359
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Yea,
    I used to do that too. Unfortunately, my web application is embedded in another application which wont display on netscape.
    It uses an old version of DynAPI, which doesn't work well on NS7, since it was really written with NS4 in mind.
    Wayne Christian

  • #4
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, the error messages in IE suck. However, if you think that this error means nothing, you could supress errors like this:

    Code:
    <script type="text/javascript">
       window.onerror = function() { return true; }
    </script>
    You could also use a try/catch block and handle the exception.
    Moderator @ WebDeveloper.com
    Mentor @ WebXpertz.net

  • #5
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    The easiest thing to do it to insert alerts in the script, that tells you the content of any varaibable, their type etc. That way you can easily see where it must lie and what causes it.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #6
    wac
    wac is offline
    Regular Coder wac's Avatar
    Join Date
    Sep 2002
    Location
    Cary, North Carolina, USA
    Posts
    359
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well, that's part of my problem. Remember, the function completes and does what its suppose to. I did put debug output all throughout the function and everything seemed fine. Normally, when I get 'Syntax Error', nothing after that point even executes. I'm getting completion and all the values seem fine.
    Wayne Christian

  • #7
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can we see your source code possibly?
    Moderator @ WebDeveloper.com
    Mentor @ WebXpertz.net

  • #8
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Why don't you try using the script debugger for this?
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •