Talk:Generate Click Events: Difference between revisions
HTMLEvents & initEvent vs MouseEvents & initMouseEvent ?? |
Freeloader (talk | contribs) No edit summary |
||
Line 28: | Line 28: | ||
[[User:Kwah|Kwah]] 16:19, 23 June 2011 (EDT) | [[User:Kwah|Kwah]] 16:19, 23 June 2011 (EDT) | ||
---- | |||
Is there a particular reason why this section doesn't mention simply calling `[http://www.w3schools.com/jsref/met_html_click.asp element.click()]` ? AFAIK, this works in both cases (either when onclick attribute is defined or with the listener). [[User:Freeloader|Freeloader]] ([[User talk:Freeloader|talk]]) 20:57, 4 December 2012 (EST) | |||
---- | ---- |
Latest revision as of 01:57, 5 December 2012
at the end:
Assume that the el variable points to some element which we want to "click on":
var evt = document.createEvent("HTMLEvents"); evt.initEvent("click", true, true); link.dispatchEvent(evt);
there is no "el variable", is "link" the right reference??? I don't want to change anything unless I'm sure that I'm right.
- Good catch. Fixed. Arantius 16:30, 1 June 2010 (UTC)
In this edit "HTMLEvents" was changed to "MouseEvents" see sample below.
Based on a brief reading of Mozilla Developers Wiki, if the example were to be changed to use "MouseEvents", initEvent should also be edited to be initMouseEvent. Long story short it should be one or the other (HTMLEvents & initEvent or MouseEvents & initMouseEvent) but not a mix of both and I do not know enough about this to be able to decide either way. Please advise whether to simply revert or edit to add initMouseEvent.
var evt = document.createEvent("MouseEvents"); evt.initEvent("click", true, true); el.dispatchEvent(evt);
Kwah 16:19, 23 June 2011 (EDT)
Is there a particular reason why this section doesn't mention simply calling `element.click()` ? AFAIK, this works in both cases (either when onclick attribute is defined or with the listener). Freeloader (talk) 20:57, 4 December 2012 (EST)