A collection of notes & ideas from the Quartz Engineering team
Consider the following:
typeof Event === 'function'
In the stock Android browser (not Chrome), it evaluates true but sometimes throws an error when you actually call it. Annoying. This statement was causing trouble on some popular devices like the Samsung Galaxy SIII.
if (typeof Event === 'function'){ var myEvent = new Event('myEvent'); // This works in every other browser that supports the Event constructor // but breaks the Android browser. Boo! } else { var myEvent = document.createEvent('Event'); myEvent.initEvent('myEvent'); }
Instead, we used this:
try { var myEvent = new Event('myEvent'); } catch (err) { var myEvent = document.createEvent('Event'); myEvent.initEvent('myEvent'); }
- Josh