这是一篇来自苹果官方的教程,原来我也没想到过,居然可以用JS来调用Object-C中的东东。其实想想,这应该是可以,要知道,象maxthon这些浏览器,可就是早就能够调用他们的核心组件了,当然,也是用JS的。firefox也是类似。。。所以Safari应该也是可以支持的。
官方文章地址是:http://developer.apple.com/library/mac/#documentation/AppleApplications/Conceptual/SafariJSProgTopics/WebKitJavaScript.html
看看他们是怎么写的,
Important: This is a preliminary document. Although it has been reviewed for technical accuracy, it is not final. Apple is supplying this information to help you adopt the technologies and programming interfaces described herein. This information is subject to change, and software implemented according to this document should be vetted against final documentation. For information about updates to this and other developer documentation, you can check the ADC Reference Library Revision List. To receive notification of documentation updates, you can sign up for a free Apple Developer Connection Online membership and receive the bi-weekly ADC News e-mail newsletter. See http://developer.apple.com/products/for more details about ADC membership.)
还有。。。
Who Should Read This Document?
This document is designed for a number of different audiences:
-
If you are a web content developer—developing web sites and embedded JavaScript applications—you should read about Safari’s JavaScript support and how scripts operate within WebKit-based applications.
-
If you are a Cocoa and WebKit developer, you should read about how to integrate JavaScript into your WebKit views and how to enhance your user experience in doing so.
-
If you are a Dashboard developer, you should read about integrating JavaScript into your widgets to provide a better user experience and more advanced features to your users.
Organization of This Document
The topic contains the following articles:
-
“About JavaScript and the DOM” describes the JavaScript language and its implementation in Safari and WebKit.
-
“Using the Document Object Model From JavaScript” discusses the Document Object Model and how to use it from JavaScript.
-
“Using the Canvas” describes the canvas object, a critical part of Dashboard but also useful within other WebKit applications.
-
“Using the Pasteboard From JavaScript” describes how to implement copy and paste functionality within embedded JavaScript applications.
-
“Using Drag and Drop From JavaScript” describes how to use Mac OS X drag and drop functionality from within Safari and WebKit windows.
-
“Using XMLHttpRequest Objects” describes how to request data from network resources using the
XMLHttpRequest
object. -
“Calling Objective-C Methods From JavaScript” describes how to use Objective-C in the JavaScript scripting environment, either within a WebKit object or by using a custom browser plug-in.
See Also
-
Safari HTML Reference provides descriptions of HTML tags, attributes, and other markup.
-
Safari CSS Reference provides descriptions of CSS properties and constants.
-
Safari Web Content Guide provides information about designing web content for iPhone.
-
Dashboard Programming Topics provides information on the technologies available to you when creating a Dashboard widget. Additional Dashboard documents and sample code can be found in the Reference Library > Apple Applications > Dashboard.
-
Apple JavaScript Coding Guidelines provides general tips about the JavaScript programming language.
-
The Reference Library > Apple Applications > Safari section of the ADC Reference Library provides useful information on WebKit, the technology that provides Apple’s JavaScript runtime.
果然还是官方的资料最多,NND,平时搜点资料都搜不到,还是官方给的方案最多啊。