1024programmer Java Differences between organized event objects in IE and Firefox browsers_javascript skills

Differences between organized event objects in IE and Firefox browsers_javascript skills

window.event
IE: There is a window.event object
FF: There is no window.event object. Event objects can be passed as arguments to functions. For example, Onmousemove=doMouseMove(event)
Current mouse coordinates
IE: event.x and event.y.
FF: event.pageX and event.pageY.
Common: Both have event.clientX and event.clientY properties.

The current coordinates of the mouse (plus the distance the scroll bar has rolled)
IE: event.offsetX and event.offsetY.
FF: event.layerX and event.layerY.
The x and y coordinate positions of the tag: style.posLeft and style.posTop
IE: Yes.
FF: No.
Common: object.offsetLeft and object.offsetTop.

Height and width of the form
IE: document.body.offsetWidth and document.body.offsetHeight. Note: The page must have a body tag at this time.
FF: window.innerWidth and window.innerHegiht, and document.documentElement.clientWidth and document.documentElement.clientHeight.
Common: document.body.clientWidth and document.body.clientHeight.

Add event
IE: element.attachEvent(“onclick”, func);.
FF: element.addEventListener(“click”, func, true).
Common: element.Onclick=func. Although the onclick event can be used, the effects of onclick and the above two methods are different. onclick only executes one process, while attachEvent and addEventListener execute a process list, that is, multiple processes. For example: element.attachEvent(“onclick”, func1);element.attachEvent(“onclick”, func2) so that both func1 and func2 will be executed.

Custom attributes of tags
IE: If an attribute value is defined for tag p1, the value can be obtained by p1.value and p1[“value”].
FF: Cannot be obtained using p1.value and p1[“value”].
General: p1.getAttribute(“value”).

Parent node, child node and delete node
IE: parentElement, parement.children, element.romoveNode(true).
FF: parentNode, parentNode.childNodes, node.parentNode.removeChild(node).

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/631981

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索