Collated comparison of full event pairs like the differences between ie and firefox

  • 2020-03-30 00:00:29
  • OfStack

Window. The event
IE: there is a window.event object
FF: no window.event object. You can pass the event object as an argument to a function. Such as onmousemove = doMouseMove (event)
Current mouse coordinates
IE: event.x and event.y.
FF: event.pagex and event.pagey.
General: both have event.clientx and event.clienty properties.

Current mouse coordinates (plus the distance the scroll bar has traveled)
IE: event.offsetx and event.offsety.
FF: event.layerx and event.layery.
Coordinates of x and y of the label: style.posleft and style.postop
FF: no.
General: object.offsetleft and object.offsettop.

The height and width of the form
IE: the document body. The offsetWidth and document. Body. OffsetHeight. Note: the page must have a body tag.
FF: window. InnerWidth and window. InnerHegiht, as well as the document. The documentElement. ClientWidth and document. DocumentElement. ClientHeight.
General: the document body. ClientWidth and document. Body. ClientHeight.

Add event
IE: element. AttachEvent (" onclick ", func); .
FF: element.addeventlistener (" click ", func, true).
General: element.onclick=func. Although both can use the onclick event, the onclick effect is different from the above two methods. Onclick only executes one procedure, while attachEvent and addEventListener execute a list of procedures, that is, multiple procedures. For example: element. AttachEvent (" onclick ", func1); Element. AttachEvent (" onclick ", func2) so that both func1 and func2 are executed.

Custom attributes of the tag
IE: if an attribute value is defined for the tag div1, it can be obtained by div1.value and div1[" value "].
FF: div1.value and div1[" value "] cannot be used.
General: div1.getattribute (" value ").

Parent, child, and delete nodes
IE: parentElement, parement. Children, element.romovenode (true).
FF: parentNode, parentNode.childnodes, node. ParentNode. RemoveChild (node).

Related articles: