Fork me on GitHub

kindeditor浏览器兼容性问题

1、kindeditor在IE下出现异常“对象不支持“attachEvent”属性或方法”

  通过开发人员工具会发现:

   这时问题就很明了,也就是IE11版本不支持“attachEvent”;

  解决方案:通过window.attachEvent和window.addEventListener监听事件,完美解决问题!

  

2、addEventListener的使用方式:

  target.addEventListener(type, listener, useCapture);

  target: 文档节点、document、window 或 XMLHttpRequest。
  type: 字符串,事件名称,不含“on”,比如“click”、“mouseover”、“keydown”等。
  listener :实现了EventListener 接口或者是 JavaScript 中的函数。
  useCapture :是否使用捕捉,一般用 false 。

    例如:document.getElementById("testText").addEventListener("keydown", function (event) { alert(event.keyCode); }, false);

3、target.attachEvent(type, listener);
  target: 文档节点、document、window 或 XMLHttpRequest。
  type: 字符串,事件名称,含“on”,比如“onclick”、“onmouseover”、“onkeydown”等。
  listener :实现了 EventListener 接口或者是 JavaScript 中的函数。
  例如:document.getElementById("txt").attachEvent("onclick",function(event){alert(event.keyCode);});

4、两者区别

  在IE10及以下版本兼容attachEvent,IE11及火狐兼容addEventListener但不兼容attachEvent

 

6、弹出窗体在IE9和IE8中不居中

  通过调试发现,在“autoPos”函数中两次返回的X值竟然不一样,具体为什么也没有深入研究:

  

  解决方案:定义一个全局变量leftW

  

  

 

posted @ 2014-10-23 08:50  迁梦余光  阅读(730)  评论(0编辑  收藏  举报