Some differences in IE and Mozilla under DHTML

xiaoxiao2021-03-05  48

Some differences in IE and Mozilla under DHTML

1--12 is a FASON (Coffee Man) Summary 1 DOM on the 1 DOM basically still consistent, but it is found that the DOM under Mozilla is more standard, and there will be some minor differences in IE. However, there is independent. 2. On the event model, this area is different. E. Target undermozilla is equivalent to Event.Srcelement under IE, but the details are different, the latter is returned to an HTML ELEMENT and E.TARGET returns It is a node, which means that the text node is included, and the method can be like this var trg = e.target; while (Trg.NodeType! = 1) TRG = trg.parentnode;

E.WHICH under mozilla is quite right with Event.Keycode under IE

Compared to E.Layerx, E.Layery, E.Pagex, E.Pagey ... you can take a look at http://fason.nease.net/mozilla/dom/ Event part

Event Binding Mozilla with AddeventListener, RemoveEventListener, corresponding IE Attachevent, DetatChevent

3. The object is directly document.getlementByid, if you need to be compatible with IE4, you can add Document.all to determine the reference to form element to standard some var oinput = document.FormName.Elements ["INPUT1"]

4. XML's application is more important, because IE is created by ActiveX, and Mozilla is already these objects (requires DOM2 support) XMLDOMDocument: var document (",", ", NULL) XMLHTTP: VAR Req = new xmlhtpRequest ()

5. InnerText is not supported in Mozilla, you need to use some Range skills to get its text

6.NsertAdjacenthtml is a more advantageous way, Mozilla can be compatible with the DOM method INSERTBEFORE

7. Some methods, such as Array, Date IE and Mozilla will also have some minor differences, which are not mentioned. . .

8. Delete an object, use DOM's approach is VAR P = Obj.ParentNode; p.RemoveChild (OBJ);

9.Select's Option increase and delete, no add and removehttp: //fason.nease.net/samples/js/moveoptions.html

10.Mozilla Handling the right button, DOM2 has supported OnContextMenu, not using E.WHICH == 2 to determine

12.