views:

1823

answers:

3

I have a Cocoa app that uses a WebView to display an HTML interface. How would I go about calling an Objective-C method from a Javascript function within the HTML interface?

+7  A: 

This is documented at developer.apple.com.

Adam Wright
Thanks, somehow missed that in my Google searches :)
georgebrock
A: 

i have a solution using NimbleKit.....where i can call objective c function from javascript..

Rony
A: 

If you wanna do it in iPhone apps, you would need to do a trick with the UIWebViewDelegate method shouldStartLoadWithRequest:

This api http://code.google.com/p/jsbridge-to-cocoa/ does it for you. It is very lightweight.

Terry