Skip to content

Instantly share code, notes, and snippets.

@ales-vilchytski
Created March 18, 2015 06:38
Show Gist options
  • Save ales-vilchytski/b6dceaf2daeeaac9ece7 to your computer and use it in GitHub Desktop.
Save ales-vilchytski/b6dceaf2daeeaac9ece7 to your computer and use it in GitHub Desktop.
JS browser markup debug helpers
// Mouse events emulation
var dispatchMouseEvent = function(target, var_args) {
var e = document.createEvent("MouseEvents");
// If you need clientX, clientY, etc., you can call
// initMouseEvent instead of initEvent
e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1));
target.dispatchEvent(e);
};
dispatchMouseEvent(document.getElementById('dijit_form_TextBox_10'), 'mousedown', true, true);
dispatchMouseEvent(element, 'mousedown', true, true);
dispatchMouseEvent(element, 'click', true, true);
dispatchMouseEvent(element, 'mouseup', true, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment