I'm using attachEvent for a while, but it seems that IE doesn't support this anymore?
window.attachEvent("onload",Start_Wysiwyg);
window.attachEvent("onscroll",ScrollEditBar,false);
Does anyone have a solution for this problem?
I'm using attachEvent for a while, but it seems that IE doesn't support this anymore?
window.attachEvent("onload",Start_Wysiwyg);
window.attachEvent("onscroll",ScrollEditBar,false);
Does anyone have a solution for this problem?
.attachEvent()
is deprecated in IE9+, and has been removed in IE11.The standard is
.addEventListener()
(MSDN docs). The MDN docs have a section about compatibility.You can simply run some feature-checking code to check if the supported features exist:
If you have to attach a lot of event listeners, then you may want to just cache the desired listener attachment method in a variable and use that variable for attaching your events throughout your code, rather than having that above check for every single event listener:
You can read more in a duplicate question linked by @MartyIX in a comment on your question. There are further nuances and methods in the answers/comments there, such as IE9 requiring
<!DOCTYPE html>
in order to use.addEventListener()
.