Over a million developers have joined DZone.

Fire Javascript DOM Events

·
Fire Javascript DOM events

function fireEvent(obj, evt) {
  var fireOnThis = obj;
  if (document.createEvent) {
    var evObj = document.createEvent("MouseEvents");
    evObj.initEvent(evt, true, false);
    fireOnThis.dispatchEvent(evObj);
  else if (document.createEventObject) {
    fireOnThis.fireEvent("on" + evt);
  }
}


Usage: clicking on a link using Javascript

HTML
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}