Use `$window.attachEvent` instead of `$window.addEventListener` on IE8

This is a fix to make localStorage work properly on IE8.

window.addEventListener doesn't exists in IE8, use window.attachEvent instead.

https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener