Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
For every Browser except lower than IE9, which you shouldn't support anyway (imho).
var evt = document.createEvent('Event');
evt.initEvent('bbEvent', true, true);
var customEventData = {
dataString: "Hello",
dataArray: ['W', 'o', 'r', 'l', 'd']
}
evt.data = customEventData;
element.dispatchEvent(evt);
window.addEventListener('bbEvent', function (event) {
console.log(event.data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.