Nicolás Lichtmaier wrote:
Quote:
Hi, some time ago I've written an article about this issue. It explain
some differences in Explorer's and Mozilla's JavaScript/DOM. It has
recently changed its URL, This is the new one: http://www.reloco.com.ar/mozilla/compat.html
Bye!
PS: I hope it's useful to someone. I would appreciate any comments and
suggestions! |
Nicolás,
Here's some feedback and improvement suggestions on your page.
1- srcElement: you write "The same, but in Mozilla the nodes of type
text can also fire events,(...)". That's not true. It's the target
property of the event object and there is a large consensus on the web
regarding this.
2- offsetX, offsetY (for event object): you write "If event.target is in
a normally (static) positioned element these properties will give you
the offset with respect to the page." That's not true; that's not
precise. When an object is statically positioned, then offsetLeft and
offsetTop return x and y coordinates relative to the document root
element. I would remove that sentence. What you write would be true for
objects (not event object) and for offsetLeft and offsetTop properties
and the following code would be correct:
var Element = evt.target ;
var CalculatedTotalOffsetLeft = CalculatedTotalOffsetTop = 0 ;
while (Element.offsetParent)
{
CalculatedTotalOffsetLeft += Element.offsetLeft ;
CalculatedTotalOffsetTop += Element.offsetTop ;
Element = Element.offsetParent ;
} ;
OffsetXForMozilla = evt.pageX - CalculatedTotalOffsetLeft ;
OffsetYForMozilla = evt.pageY - CalculatedTotalOffsetTop ;
In my own homepage (at this precise url; you need MSIE 6 to view it)
http://www10.brinkster.com/doctorunc...l#NoteOffsetXY
, I wrote "Under NS 6+, it is possible to calculate [directly] the
offsetX/Y values." and I still think this is true.
3- window.screenX, window.screenY are not the equivalent to MSIE's
window.screenLeft, window.screenTop
If you open the explorer bar or activate the Tip of the day frame,
you'll see that values are different, they change. If you open the
sidebar in Mozilla, window.screenX won't change.
http://www10.brinkster.com/doctorunc...enLeftTop.html
4- document.defaultView is NOT the equilavent of document.parentWindow.
document.contentWindow is the equivalent to document.parentWindow
Note here:
See/try
http://bugzilla.mozilla.org/attachme...09&action=view
from bug 151300 at bugzilla.
Also, bug 228497: contentWindow is not implemented on document
http://bugzilla.mozilla.org/show_bug.cgi?id=228497
5- innerText: "There's no direct mozilla equivalent." Strictly speaking,
that is not true as Mozilla 1.5+ implement DOM 3 Core method textContent.
http://www.w3.org/TR/2004/REC-DOM-Le...e3-textContent
I think your document should just give an example of how to replace
innerTtext with a working example.
E.g.:
<p id="idText">Hello world!</p>
document.getElementById("idText").innerText
can be replaced with
document.getElementById("idText").firstChild.nodeV alue
Depending on the specific need of the scripter, some CharacterData
method might be more relevant to use.
6- MyForm: "You must use document.myForm" The scripter might also use
document.forms["myForm"]
or even
document.forms[ordinalInteger] which will be XHTML compliant as well. I
would at least change your "must" to "may" in your file and offer the 2
other alternatives.
In your "Parentheses or brackets" section, you write
"One must always use [], i.e.: documents.forms[0].field.value"
Finally, I invite you to participate (feedback, suggestions, ideas) in
bug 74952.
DU