Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Apr 7, 2008, 10:27 PM   #1
macrumors regular
Join Date: Oct 2007
Location: Hong Kong, or Surrey, BC, Canada
Cocoa WebView to Open Links in Default Browser

Hi all,

I'm wondering if there is a way to make a WebView to open a link with the system's default browser?

nikiski is offline   0 Reply With Quote
Old Apr 7, 2008, 11:25 PM   #2
Moderator emeritus
kainjow's Avatar
Join Date: Jun 2000
You need to set the web view's policy delegate, and then implement the webView:decidePolicyForNavigationAction:request:frame:decisionListener: method, something like this:

- (void)webView:(WebView *)sender
        decidePolicyForNavigationAction:(NSDictionary *)actionInformation
        request:(NSURLRequest *)request
        frame:(WebFrame *)frame
        decisionListener:(id <WebPolicyDecisionListener>)listener
{[listener ignore];
    [[NSWorkspace sharedWorkspace] openURL;[request URL]];

Edit: I can't get that code to format, but it should do what you need.
kainjow is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Chrome is default browser, but some things still open in Safari? joejoejoe Mac Applications and Mac App Store 4 May 25, 2014 06:54 PM
Mail links won't open in browser NeoCool Mac Basics and Help 1 Jul 19, 2013 08:35 AM
changing the default browser that Facebook opens links to kat.hayes Alternatives to iOS and iOS Devices 3 May 30, 2013 11:30 AM
Mercury browser -open links? Hooterville iPad Apps 0 Mar 8, 2013 09:29 PM
WebView in Cocoa (Objective-C) tr!pf!3 Mac Programming 0 Aug 28, 2012 09:48 AM

Forum Jump

All times are GMT -5. The time now is 12:52 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC