开发者

dojo cross browser compatibility

开发者 https://www.devze.com 2023-02-03 22:46 出处:网络
I recently posted a question on stackoverflow about the less popular js function document.captureEvents(). For most browsers, it is not necessary to use this capture. The question and answers are here

I recently posted a question on stackoverflow about the less popular js function document.captureEvents(). For most browsers, it is not necessary to use this capture. The question and answers are here:

javascript :Object doesn't support this property or method

However, it was suggested to be absolutely safe, a dojo solution should be used to abstract away browser differences.

I found some dojo code samples on the web related to generic usage i.e. using dojo syntax to declare form inputs etc. But is there an example to use dojo for this particular problem of document.captureEvents(). In short, how to do document.captureEvents in dojo. Is dojo suited for this particu开发者_如何学Pythonlar problem case?


Dojo makes handling events very easy. If you wanted to capture mouse up event on the page as your other question seems to do, you would use:

dojo.connect( dojo.body(), 'mouseup', function( event ) { console.log( event ); } );

Replacing the function body with whatever functionality you need.


I believe your real question involves how to properly capture events in modern browsers, in which case you might like to start with a page such as this:

http://dojotoolkit.org/reference-guide/quickstart/events.html

As Pekka hinted at, pretty much any successful JS lib today (jQuery, Dojo. Prototype, MooTools, YUI, etc.) provides abstractions involving listening for DOM events. In Dojo the analogue is dojo.connect.

  • http://dojotoolkit.org/reference-guide/dojo/connect.html (reference guide)
  • http://dojotoolkit.org/api/dojo/connect#dojo.connect (API doc)
0

精彩评论

暂无评论...
验证码 换一张
取 消