On Oct 23, 2008, at 11:16 AM, Benjamin Dobson wrote:

On 23 Oct 2008, at 01:09:07, <[EMAIL PROTECTED]> <[EMAIL PROTECTED] > 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 PROTECTED]


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to