Created
May 22, 2013 04:43
-
-
Save acmcelwee/5625294 to your computer and use it in GitHub Desktop.
Event trigger (this works with document.addEventListener)
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 triggerEvent(element, eventType) { | |
var e; | |
if (document.createEventObject) { | |
//ie | |
e = document.createEventObject(); | |
element.fireEvent(eventType, e); | |
} else { | |
//others | |
e = document.createEvent('HTMLEvents'); | |
e.initEvent(eventType, true, true); | |
element.dispatchEvent(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment