Closed
Bug 22654
Opened 25 years ago
Closed 25 years ago
OnClick can't be attached to via an XHTML externally referenced javascript file
Categories
(Core :: XML, defect, P3)
Tracking
()
VERIFIED
INVALID
M17
People
(Reporter: angjh, Assigned: nisheeth_mozilla)
References
Details
Attachments
(2 files)
A document with the following starting fragment:
<?xml version="1.0"?>
<?xml-stylesheet href="somefile.css" type="text/css"?>
<Client xmlns:html="http://www.w3.org/TR/REC-html40">
<html:script type="text/javascript" language="javascript"
src="somefile.js"/>
That declares the following script in "somefile.js":
function document_onClick(evt) {
alert("hey!");
}
document.onclick = document_onClick;
Should, when browsed through Mozilla, display an alert when clicked anywhere on
the document. This does not work. I also tried placing the code directly in the
script block instead of externally referencing it and this didn't seem to help
either. The ability to externalize behavior associated with XML elements is a
very powerful one (MS is cleanly hooking script to elements with DHTML
behaviors) and a must have for a solid web application development platform.
| Assignee | ||
Updated•25 years ago
|
Status: NEW → ASSIGNED
Target Milestone: M16
| Assignee | ||
Comment 1•25 years ago
|
||
This issue is related to whether an XHTML document exposes an HTML DOM or an XML
DOM. Currently, the XML DOM is exposed so "document.onclick" is not supposed to
work in XHTML. See bug 7833 for more discussion on this topic. CCing Vidur
for an update on what the DOM working group thinks about this.
Setting target milestone to M16...
| Assignee | ||
Comment 3•25 years ago
|
||
On re-reading this bug, I feel that your test case is an XML document and will ,
therefore, never expose the HTML Document DOM. So, document.onclick is never
going to work for the case you described.
I think the real question to ask here is the following. Do the DOM 2 event apis
specify a way for scripts to listen to events inside XML documents. If they do,
what is the status of their implementation in Mozilla? Re-assigning this bug to
joki because he's the events god.
Assignee: nisheeth → joki
Status: ASSIGNED → NEW
| Assignee | ||
Comment 4•25 years ago
|
||
| Assignee | ||
Comment 5•25 years ago
|
||
| Assignee | ||
Comment 6•25 years ago
|
||
Tom, if you save the attached test.xml and test.js in the same directory and
load test.xml, you'll see a JS alert. This means that the test.js file is
getting loaded and executed properly.
Comment 7•25 years ago
|
||
Okay, funky. So the problem isn't with the event listeners. The problem is
with the script running. After the first alert dialog box runs the script
stops. I haven't looked into why yet. I was going to recommend replacing the
document.onclick = document_onClick;
with
document.addEventListener("click", document_onClick, false);
per the DOM Level 2 spec but it actually seems that these both work, the problem
is the alert box. If you try putting two alert boxes in a row here you'll see
that only one gets called. Weird. Well I'm going to bounce this back to you
nisheeth for the script analysis.
Assignee: joki → nisheeth
| Assignee | ||
Comment 8•25 years ago
|
||
The test case works fine. The document.onclick syntax is invalid inside an XML
document because only the DOM Core interfaces are useable inside an XML
document.
Marking bug invalid.
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → INVALID
Verified.
Status: RESOLVED → VERIFIED
Keywords: verifyme
| Comment hidden (collapsed) |
You need to log in
before you can comment on or make changes to this bug.
Description
•