Skip to content

Instantly share code, notes, and snippets.

@rfadams
Created January 10, 2012 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfadams/1591639 to your computer and use it in GitHub Desktop.
Save rfadams/1591639 to your computer and use it in GitHub Desktop.
Simulate Click inside Gmail
simulateClick = null;
function simulateClick() {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("mousedown", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
var cb = document.getElementById("canvas_frame").contentWindow.document.getElementById(":pg");
var canceled = !cb.dispatchEvent(evt);
console.log("innerText: " + cb.innerHTML);
console.log("class: " + cb.class);
if(canceled) {
// A handler called preventDefault
console.log("canceled");
} else {
// None of the handlers called preventDefault
console.log("not canceled");
}
}
simulateClick();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment