Last active
December 16, 2015 10:09
-
-
Save jesse1981/5418388 to your computer and use it in GitHub Desktop.
Script a click event to object.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fakeClick(event, anchorObj) { | |
if ((typeof(anchorObj)!="undefined") && (typeof(anchorObj.click)!="undefined")) { | |
anchorObj.click() | |
} | |
else if(document.createEvent) { | |
if(event.target !== anchorObj) { | |
var evt = document.createEvent("MouseEvents"); | |
evt.initMouseEvent("click", true, true, window, | |
0, 0, 0, 0, 0, false, false, false, false, 0, null); | |
var allowDefault = anchorObj.dispatchEvent(evt); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment