user1876657
user1876657

Reputation: 71

Calling JavaScript from Obj C - Without a WebView

Is there a way to call a JavaScript function from an Objective-C method without using a web view? What I want to do is to simulate pressing a link (say Add) on a webpage, whenever an NSButton is pressed. I know which JavaScript function is called, whenever 'Add' is pressed.

I don't have a web view in the app and this is not an iPhone app.

Upvotes: 1

Views: 171

Answers (1)

user529758
user529758

Reputation:

This is not an iPhone app.

In this case, you're lucky - you can use the JavaScriptCore framework for calling JavaScript from C programs.

(For future reference: this framework is also available on iOS, but it's private - you can use it for in-house and jailbroken development, but not in an AppStore app. Opensource ports of Apple's JavaScriptCore exist as well, as pointed out by @JustSid.)

Upvotes: 2

Related Questions