kindeditor上传图片浏览器兼容性问题

2025-02-03 01:57:25
推荐回答(1个)
回答1:

您好,
通过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

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

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