Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【js】IE 的事件处理和 W3C 的事件处理有哪些区别? #126

Open
misty0304 opened this issue May 22, 2020 · 1 comment
Open

Comments

@misty0304
Copy link
Owner

No description provided.

@misty0304
Copy link
Owner Author

绑定事件

  • W3C: targetEl.addEventListener('click', handler, false);
  • IE: targetEl.attachEvent('onclick', handler);

删除事件

  • W3C: targetEl.removeEventListener('click', handler, false);
  • IE: targetEl.detachEvent(event, handler);

事件对象

  • W3C: var e = arguments.callee.caller.arguments[0]
  • IE: window.event

事件目标

  • W3C: e.target
  • IE: window.event.srcElement

阻止事件默认行为

  • W3C: e.preventDefault()
  • IE: window.event.returnValue = false'

阻止事件传播

  • W3C: e.stopPropagation()
  • IE: window.event.cancelBubble = true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant