How would I go about developing cross-browser event triggering for mouse buttons (left, middle and right) in plain-vanalla JavaScript?
A:
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
gg
2009-11-27 00:15:47
Please, stop asking that sort of questions, and better try answering mine.
David Gore
2009-11-27 00:22:53
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...
gg
2009-11-27 00:33:10
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
2009-11-27 00:52:09
Ridiculous? What's so ridiculous? I asked gg not to demand a valid reason from me because that doesn't pertain to my question.
David Gore
2009-11-27 01:24:23
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
jitter
2009-11-27 01:41:22
He He!!! I am from Russia. A fat lot we care about license violations! =) But back to my business. I do not want just use what could/should be done myself. I study JS, so it is important for me to do things myself. Frameworks are good but they perhaps deprive me of understanding the real core of JS. And after all, I just don't need the whole libraly to do the triggering, do I?
David Gore
2009-11-27 01:56:24
I was kidding about copying the code :) sarcasm, fail... :) I understand you would like to do this yourself, but I think you will find its a great amount of work with very little reward. Rather spend your effort on learning the good parts of Javascript, not the crappy dom aspect of it. JQuery is simply a tool that allows you focus on the good aspects and not worry about browser compatibility etc. Douglas Crockford has a really good book on Javascript called "JavaScript: The Good Parts". It's worth the read.P.S. jitter's answer should be marked as the correct one...
gg
2009-11-27 09:19:50
+4
A:
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
jitter
2009-11-27 00:49:10
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.
Crescent Fresh
2009-11-27 03:00:37
Upped you and commented that yours should be accepted as the correct one. More in scope with question.
gg
2009-11-27 09:21:06