Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 7, 2008, 10:27 PM   #1
nikiski
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?

Thanks.
__________________
Woof!
nikiski is offline   0 Reply With Quote
Old Apr 7, 2008, 11:25 PM   #2
kainjow
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:

Code:
- (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

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Open media links in browser w/ Quicktime, not VLC PkennethV Mac Basics and Help 0 Aug 1, 2011 11:15 PM
Is there a way to open URL in different browser from mail? yalag OS X 3 Jan 19, 2011 06:09 AM
get safari to open links in new tab otis123 Mac Applications and Mac App Store 2 Feb 24, 2009 05:20 PM
Is there a way to open links in new windows? CBell iPhone Tips, Help and Troubleshooting 0 Nov 6, 2008 09:37 AM
Safari open link in another browser cemorris Mac Applications and Mac App Store 0 Mar 18, 2008 10:42 AM


All times are GMT -5. The time now is 09:57 AM.

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

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