http://www.kirupa.com/html5/custom_events_js.htm
1
2
3
4
5
6
7
8
document.body.addEventListener("myEventName", doSomething, false);
function doSomething(e) {
alert("Event is called: " + e.type);
}
var myEvent = new CustomEvent("myEventName");
dodocument.body.dispatchEvent(myEvent);
origin - http://www.pipiscrew.com/?p=2572 js-custom-events-in-javascript