onClick events on checkboxes don't work if they call a function

VERIFIED INVALID

Status

()

Core
JavaScript Engine
--
enhancement
VERIFIED INVALID
15 years ago
15 years ago

People

(Reporter: Jamie Kosoy, Assigned: rogerl (gone))

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

15 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; (R1 1.3))
Build Identifier: Mozilla/5.0

In the page listed above, an onClick javascript event is called on each of the 
checkboxes. While an event would work fine if javascript was called straight 
from the invididual checkbox, the code does not work at all when it is sent to 
a function.

Reproducible: Always

Steps to Reproduce:
1. Create a simple javascript function (even "Hello World")
2. Create an HTML checkbox within the BODYTAG.
3. Attach onClick="your function"
4. Save and attemp to run

Actual Results:  
Nothing. Which is the exact problem.

The checkbox is rendered completely inactive. It remains on either its true or 
false state, depending on whatever it was intiially set to.

Expected Results:  
The checkbox should call the Javascript function and perform the desired task.

Comment 1

15 years ago
Sorry, have to mark this one invalid.

The problem is, you named your function "goto". This is a reserved word
according to the spec for the JavaScript language. See Section 7.5.3 in 
http://www.mozilla.org/js/language/E262-3.pdf.

Reserved words may not be used as identifiers (e.g. function names).
The fact that IE allows it indicates IE does not adhere to the spec.

Note: you can see what's going wrong in Mozilla by using Mozilla's
Tools > Web Development > JavaScript Console. Be sure to clear it
of any previous errors first. Then, when you load the page you will
see an error because it cannot parse the function name. When you 
click on the uppermost checkbox, you will get another error indicating
the reserved-word problem.

If you rename your function to something else (non-reserved!),
your testcase should work -
Status: UNCONFIRMED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → INVALID

Comment 2

15 years ago
Another suggestion: you are hard-coding "JavaScript 1.2"
as the language attribute in your script tag:

            <script language="javascript1.2">

Unless you need to use the special quirks of JS1.2, you should
avoid hard-coding the version of the language. Instead, do this:

            <script language="javascript">

That will force the browser to use the latest version of the
language available (which is currently 1.5). A number of bug
fixes and refinements have occurred between JS1.2 and JS1.5.
Generally, the latest version of the language is preferable -
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.