[thelist] Javascript newbie - errors

Simon Willison cs1spw at bath.ac.uk
Fri Oct 24 23:20:31 CDT 2003


Tim Burgan wrote:

> If anyone has some spare time can you please take a look a webpage I'm
> creating [1] to teach myself JavaScript.
> 
> I'm having errors. All the JavaScript is embedded into the page. I'm
> only concerned about Internet Explorer at the moment.

Mozilla Firebird is a much better tool for developing and debugging 
Javascript than IE. According to the Firebird Javascript Console 
(accessible from the tools menu) your code has the following problems:

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 />");

You're also missing definitions for task2(), task3(), task4() and task5().

 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 />")

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).

-- 
Simon Willison
Web development weblog: http://simon.incutio.com/



More information about the thelist mailing list