Use `$window.attachEvent` instead of `$window.addEventListener` if it does't exist (IE8).