Can I use jQuery in developing a Mac OS X Dashboard widget?
Quick question: can I use a JavaScript library (i.e. jQuery) in developing a Mac O开发者_JAVA技巧S X Dashboard widget?
EDIT: I know that if so, I'll need to pack a local version of the library and not use one from an online CDN.
Considering that an OS X dashboard widget is really nothing more than a mini webpage running locally, and that jQuery is nothing more than a huge amount of javascript, I'd say yes.
Googling I found this site which seems to confirm: http://www.reynoldsftw.com/2009/03/os-x-dashboard-widgets-with-jquery/
You can simple add <script type="text/javascript" src="jquery-1.6.1.js" charset="utf-8"></script>
in the head part in your main.html file. Of course you have to download jquery and place the jquery-1.6.1.js in the file ssection (down left of the DashCode application).
Another solution could be <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" charset="utf-8"></script>
but that requires that you allow Network Access in the attributes
The purpose of jQuery is to make dealing with browser inconsistencies painless. OS X dashboard widgets solely use the WebKit engine. So, why would you want to include code that performs unnecessary actions (e.g. browser detection) instead of just writing WebKit specific JavaScript?
精彩评论