element.addEventListener breaks IE8
Closed this issue · 5 comments
- Love the project
- Unfortunately, it seems that heyoffline.js:24 (return element.addEventListener(event, fn, useCapture);) gives this error:
"Object doesn't support this property or method"
- After a little research, it seems that if the addEventListener function is not available you can use attachEvent.
- I'll give it a shot and see if I can contribute a fix for it, but no guarantees :)
I tried this:
if(element.addEventListener) {
return element.addEventListener(event, fn, useCapture);
} else {
return element.attachEvent('on'+event, fn);
}
, and that worked, but then there was another error further down the page at line 36 (unrelated?):
_results.push(element.style[key] = !isNaN(value) ? "" + value + "px" : value);
"Invalid argument." -- value, in this case, came through as undefined. I spent a little time trying to debug through my VM, but figured I'd let it be for now.
Gave it a shot!
Glad you like it.
The lib is not ment for IE, since it probably doesn't even support the online/offline events. Plus, I don't own windows so it's pretty hard to test it there :-)
If you want to give it a shot, and try to make it work on IE, go ahead. Pull requests are highly welcome. But I guess one would have to use intervals and that's a whole another story.
That said, a good idea would be not to throw JS errors under IE.
Ah, gotcha. Had a rude awakening when I included the JS in the body and not
the head and then my single-page app failed on IE8 :)
I'll revisit another time, but it is probably not worth it. Keeping it in
the allows it to be there and work when it can.
Thanks,
Robert
On Tue, Dec 4, 2012 at 2:30 PM, Oskar Krawczyk notifications@github.comwrote:
Glad you like it.
The lib is not ment for IE, since it probably doesn't even support the
online/offline events. Plus, I don't own windows so it's pretty hard to
test it there :-)If you want to give it a shot, and try to make it work on IE, go ahead.
Pull requests are highly welcome. But I guess one would have to use
intervals and that's a whole another story.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/13#issuecomment-11011562.
TrueOnline will be of interest:
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&ie=UTF-8#hl=en&tbo=d&sclient=psy-ab&q=TrueOnline%20plugin&oq=&gs_l=&pbx=1&fp=40afe6cabb4988bd&bpcl=40096503&ion=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&bvm=bv.1355534169,d.aWM&biw=1047&bih=623
Digging up the most recent version now and will post back on github for further development
I started writing this comment: "Actually, some jQuery like this would be more helpful for checking if you're currently online " paused, and then tied together this library, check-online.js: