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脚本兼容 #6

Open
Kelichao opened this issue Jan 21, 2017 · 0 comments
Open

【js兼容】IE脚本兼容 #6

Kelichao opened this issue Jan 21, 2017 · 0 comments

Comments

@Kelichao
Copy link
Owner

Kelichao commented Jan 21, 2017

IE脚本兼容

由于IE8及以下并不支持标准ECMAScript所以其有诸多跟其他浏览器不一致的地方,主要的注意点见要点

  • 事件对象/window.event | e / 678
document.onclick = function(e) {
      console.log(window.event);// IE绑定在window上
      console.log(e);// 标准模式
}
  • 鼠标坐标/event.x | e.pageX/ 678
document.onclick = function(e) {
      console.log(window.event.x);// IE绑定在window上
      console.log(e.pageX);// 标准模式
}
  • 异步请求ajax/ ActiveXObject | XMLHttpRequest/ 6,7
var xhr = new ActiveXObject();
//标准
var xhr = new XMLHttpRequest();
  • DOM2级事件绑定attachEvent | addEventListener/ 678
alert(window.attachEvent);// IE专属
alert(window.addEventListener);// 标准,IE8以上支持
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