Re: WebView: Open new windows in default browser
Re: WebView: Open new windows in default browser
- Subject: Re: WebView: Open new windows in default browser
- From: Kevin Gessner <email@hidden>
- Date: Thu, 23 Oct 2008 12:17:01 -0400
On Oct 23, 2008, at 11:16 AM, Benjamin Dobson wrote:
On 23 Oct 2008, at 01:09:07, <email@hidden> <email@hidden
> wrote:
I've been trying to get a WebView to open in the user's default
browser. In fact, I've succeeded, but it's rather clunky,
and I'm wondering if there's a better way.
Why not simply add "target=_'blank'" to your URLs? No WebView
hacking needed.
<a href="http://my.external.url" title="What the user sees"
target="_blank"></a>
Sorry – you misunderstand. I meant a way to change the way WebView
handles opening windows to open them in the user's default browser.
Like I said, I have found a way to do this, but it involves a second
WebView which intercepts the message and passes it to the default
browser with [[NSWorkspace sharedWorkspace] openURL:[request URL]];
As such, it doesn't really matter if there is no other way to do
this, but a better method would be an improvement.
What about the WebFrameLoadDelegate (frameLoadDelegate) of your
WebView? You could intercept the click with
webView:didStartProvisionalLoadForFrame:, cancel the webview's
loading, and handle the URL yourself with NSWorkspace. I haven't
actually tried this, but it might be a more elegant solution.
Thanks,
-- Kevin
Kevin Gessner
http://www.kevingessner.com
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden