Talk:Generate Click Events: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
mNo edit summary
(HTMLEvents & initEvent vs MouseEvents & initMouseEvent ??)
Line 15: Line 15:
:Good catch.  Fixed.  [[User:Arantius|Arantius]] 16:30, 1 June 2010 (UTC)
:Good catch.  Fixed.  [[User:Arantius|Arantius]] 16:30, 1 June 2010 (UTC)


----
In [http://wiki.greasespot.net/index.php?title=Generate_Click_Events&diff=6415&oldid=6397 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.
<pre class='sample'>
var evt = document.createEvent("MouseEvents");
evt.initEvent("click", true, true);
el.dispatchEvent(evt);
</pre>
[[User:Kwah|Kwah]] 16:19, 23 June 2011 (EDT)
----
----

Revision as of 20:19, 23 June 2011

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)