Call Cocoa method from within HTML content in WebView?

retrotron

thinking is design
Is there any way to invoke a Cocoa method from some HTML content in a WebView? Suppose I have an anchor/link in an HTML page inside a WebView. When the user clicks that link, is there any way for that anchor/link to invoke a Cocoa method (e.g. tell the WebView to update the HTML content and reload the page or something)?
 
No, but you could create special fake links specifically for your Cocoa application, which you would check for in your WebView subclass.. i.e. fakeURL://action=reload
 
See the documentation for the method webView:decidePolicyForNavigationAction:request:frame:decisionListener:

You can then get the URL from the NSURLRequest variable "request", and then check for your special URL type. Then, if it's your special type, use [listener ignore]; or if not, use [listener use];
 
Back
Top