views:

46

answers:

1

Is it possible to trigger the execution of a method within an iPhone application from Javascript on a web page?

For example, I'd like to have a button that opens the iPhone camera application. Is this possible?

+2  A: 

The question is worded a bit confusingly, but if you're displaying a UIWebView in an app and want to have Javascript from the webpage interact with the app, this can be done using the webView:shouldStartLoadWithRequest:navigationType: delegate method. See Apple's documentation: http://developer.apple.com/iphone/library/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html

If you are trying to open the Camera app from an actual webpage running in Safari, you're out of luck. You can only open apps with associated URLs. (For example, tel: URLs to make phone calls, itms: URLs to launch the iTunes Store or App Store, etc).

anshuchimala