How would I go about developing cross-browser event triggering for mouse buttons (left, middle and right) in plain-vanalla JavaScript?
2 Answers
A few starting points
document.createEventelement.dispatchEventfireEventMethodcreateEventObjectMethod- event.simulate.js
- A look into how known big Javascript Frameworks do it (e.g.
jQuery) - And don't forget
- grab a cup of coffee (or better two)
- be ready to get many headaches
- be ready to encounter subtle bugs which will make you want to rip your hear out
- to make it crossbrowser you will need to do a lot(!) of testing
2 Comments
Crescent Fresh
Very nice links. Not sure why this would not have been accepted (compared to the one that was). I just want to point out (to @David as well) that point #6 does not utilize any of points 1-5. @David: you're in for a big surprise when you see the approach jQuery took in simulating events.
gg.
Upped you and commented that yours should be accepted as the correct one. More in scope with question.
It would be strongly recommended you use a Javascript Library for this purpose.
Most popular being JQuery (recommended)
For additional libraries you can view the following what-is-the-best-lightweight-javascript-framework
Do you have a valid reason for not using any libraries...?
Regards
Gordon
7 Comments
David Gore
Please, stop asking that sort of questions, and better try answering mine.
gg.
Fair enough... in reply to your question, open the jquery source code and copy the "cross-browser event triggering" code and paste it into your javascript file. Its cross browser, its been written and you can pretend its home-made...
David Gore
could you please show me which part of jQuery I should use and how to rebuild it so that I get exactly what I need. Thanks.
David Gore
Ridiculous? What's so ridiculous? I asked gg not to demand a valid reason from me because that doesn't pertain to my question.
jitter
Sorry. Forget about it. Wrote this after I took the time to gather a few relevant links and saw that you accepted the "hey just copy jQuery's solution" answer. Which upset me a little after you wrote: I want to do it myself. btw. just copying the code and pretending it is home made would be a license violation too
|
clickevent on analink won't open the link.