Saturday, December 16th, 2006
Ajax Cookbook: Helpful JavaScript tips
<>p>Bret Taylor is the guy who is responsible for the first Google Maps.He obvi0usly has a lot of experience, and has recently been on fire with a new blog called the Ajax Cookbook.
The blog focuses on small useful JavaScript snippets that do not assume a particular JavaScript/Ajax library, so they can be generally useful.
Recent examples are:
- Cross-Browser Event Handling and Memory Leaks
- Canceling and Stopping Browser Events
- JavaScript Debug Log
- Disabling the Browser Context Menu
A great addition to the space. I am looking forward to see more and more recipes, and real world experience from Bret.
Related Content:











bahh, why would he obviOusly know anything better ? because he worked on the first google maps, that’s far to be a reference to me. The 4 ONLY examples are far to be
disabling context menu
FF1.5,FF2, Opera8.52,Opera9 = no effect, considering to change the default behavior of the right mouse button is a big UI mistake. Dont consider it. Ever.
debug log
document.write, window.open, awfull tips, dont consider using it
cancel events
2 tests for each functions for EVERY cancel, no optimization at all, dont use it
cross browser events
nothing new exposed, it has been better explained a lot all over the web, once again there is NO optimization at all, no way to control the execution scope, no way to choose between DOM0 and DOM2 registration, no way to add an arbitrary object to the listener. Very bad point, you have to keep the reference to the registered listener if you want to remove it before the document unload. Dont use it, better look for a robust addEvent(), it’s easy to found, it was all over the web 6 months ago.
Let’s hope it will get any better in the future, but it looks like a dead horse giving deprecated tips with bad code practice, i doubt it to be of any use.
Laurent, excellent commentary and corrections, your optimizations are indeed much better than Bret’s.
Laurent, actually, there are some instances where disabling the browser’s context menu is useful. For instance, if you are building a browser based application, where you want to use the right click to show your own context menu, which might make more sense to the user than the browser’s menu. At my work, we’re using it in our CMS, and I’ve never heard any complaints about it.
Ron, there are always exceptions, but most of the time changing right click behavior it a bad usability choice.