[thelist] Javascript newbie - errors

Jeff Howden jeff at jeffhowden.com
Sat Oct 25 02:50:45 CDT 2003


simon,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Simon Willison
>
> Mozilla Firebird is a much better tool for developing
> and debugging Javascript than IE.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

only if your target audience is using mozilla/firebird/gecko/nn6+.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Error: missing ) after argument list
> Source File: http://www.greaterthani.com/05_programming/week2.htm
> Line: 141, Column: 128
> Source Code:
>            document.write("Expressions are components
> that make-up statements. For example, an expression is
> described as being ""like a phrase in a sentence"".
> Whereas a statement is the ""complete sentence""<br />");
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

funny, i don't see how firebird gives anymore information about the error
than ie does.  here's what i get in ie:

 Line: 141
 Char: 128
Error: Expected ')'
 Code: 0
  URL: http://www.greaterthani.com/05_programming/week2.htm

ok, so firebird included the code from the line in the document containing
the error.  however, they both correctly identify the problem (prematurely
ending the line without closing the method call).

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
>  From your code, it looks like you're escaping the
> double quotes improperly. In Javascript, you escape
> double quotes with a backslash:
>
> document.write("Expressions are components that make-up
> statements. For example, an expression is described as
> being \"like a phrase in a sentence\". Whereas a
> statement is the \"complete sentence\"<br />")
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

fwiw, this is why i made the decision *long* ago to always qualify strings
in javascript with single quotes.

document.write('Expressions are components that make-up statements. For
example, an expression is described as being "like a phrase in a sentence".
Whereas a statement is the "complete sentence"<br />');

see, no escaping necessary.  the same is true when you've got strings
riddled with html tags with attributes.  no escaping necessary there either.
the only thing you gotta watch out for then is single-quotes which occur
much less frequently in strings.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Seriously though, it's well worth developing stuff like
> this in a better browser than IE. IE allows you all
> kinds of non-standard shortcuts, so if you develop
> Javascript in it you'll end up with buggy code without
> ever realising it (because it'll Just Work).
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

just a tad dramatic.  regardless of how "good" the development/debugging
environment is, it's far more important to develop in the viewer the
audience will be using.  sure, if you've got a freak site that has a
majority of mozilla/firebird/gecko/nn6+ users, then it makes sense.
otherwise it doesn't.

let's not get into talking about all sorts of non-standard shortcuts.
mozilla isn't a saint in that regard either (script, css, xml, html, etc.,
it's all been tweaked beyond "standard").

the proper advise would warn that you should test in all the major browsers
your audience will be using because each of them have their own problems,
bugs, and shortcomings in general.  don't assume for a second that because
it works in browser a (mozilla) that it'll automatically also work in
browser b (opera) or browser c (ie).

.jeff

------------------------------------------------------
Jeff Howden - Web Application Specialist
Resume - http://jeffhowden.com/about/resume/
Code Library - http://evolt.jeffhowden.com/jeff/code/



More information about the thelist mailing list