In PhoneGap, all URLs load into WebView by default. Setting targets or being fancy with JS will not break your external links out of that WebView. In order to load external URLs into Safari, rather than the PhoneGap app itself, you need to modify the way URLs are handled in the application delegate.
Open up your PhoneGap app code and locate [projectname]AppDelegate.m ... typically found under [projectname]/Classes folder.
Modify shouldStartLoadWithRequest however you like. Here is a sample implementation that will evaluate requests and handle HTTP or HTTPS schemes to load in Safari (borrowed from http://solutions.michaelbrooks.ca/2011/02/15/open-external-links-in-safariapp/):
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
// Intercept the external http requests and forward to Safari.app
// Otherwise forward to the PhoneGap WebView
if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}
}