views:

391

answers:

1

I have an webView in a Cocoa application which I edit the contents programatically. What I wanted to do was make clicked links open in the users default browser, so I added the code at the bottom of this question. It works perfectly but if there is an iFrame on the page that loads it will open the iFrame contents in the default browser and not display the frame correctly in my app. Is there a way to tell the webview to open the links but do nothing to iFrames?

- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation
  request:(NSURLRequest *)request
    frame:(WebFrame *)frame
decisionListener:(id)listener 
{

 // Open it in the default browser
 NSURL *url = [request URL];
    if (url)
 {
  [[NSWorkspace sharedWorkspace] openURL:url];
  [listener ignore];
 }
 else
 {
  [listener use];
 }
}
A: 

Examine the navigation-action dictionary.

Peter Hosey