Over a million developers have joined DZone.

Fire Javascript DOM Events

DZone's Guide to

Fire Javascript DOM Events

Free Resource
Fire Javascript DOM events

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

Usage: clicking on a link using Javascript


Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}