title: How to open external links to safari/chrome browser in Cocoa
body: <p>I'm a newbie in Cocoa development.</p>
  
  <p>I have read about using WebPolicyDelegate. However, I can't seem to have it work the way it should. I want the app to open external links and have it launched in a web browser like chrome or safari. This should only occur whenever the link is being clicked.</p>
  
  <p>Currently, the default url of my app also opens to the web browser at the same time with what my app's webview is doing.</p>
  
  <p>I've set the policyDelegate to my webview and I used the following code for its implementation:</p>
  
  <pre><code>- (void)webView:(WebView *)webView 
  decidePolicyForNavigationAction:(NSDictionary *)actionInformation 
  request:(NSURLRequest *)request 
  frame:(WebFrame *)frame 
  decisionListener:(id &lt;WebPolicyDecisionListener&gt;)listener
  {
      if ([actionInformation objectForKey:WebActionElementKey]) {
          [listener ignore];
          [[NSWorkspace sharedWorkspace] openURL:[request URL]];
      }
      else {
          [listener use];
      }
  }
  </code></pre>
  
  <p>Any help would be much appreciated! :)</p>