Added window.attachEvent if for IE8