View Full Version : How to redirect link in application ti Safari ....

11 Feb 2011, 3:19 AM
Hi to all,
I'm doing a PhoneGap + Sencha Touch iPhone application ...

The first problemwas in a maps terms and condition like my post

But if I make a link
<a href="www.google.com">link</a>

In a tab ... when I click the google home page appear ... but the aplication disappear and I can't come back to the app ...


My question is:
is possible to force the link opening on Safari outside the current app?
or in a window ... popup ... ecc ecc

How can I do this with Sencha?


Riddler ?

11 Feb 2011, 6:43 AM
If you want to do this ... you have to modify tha AppDelegate.m file =P~
with this code:

- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

NSURL *url = [request URL];

// add any other schemes you want to support, or perform additional
// tests on the url before deciding what to do -jm

if( [[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"])
[[UIApplication sharedApplication] openURL:url];
return NO;
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];


... and NOW ... your link open and wieving with Safari :))

I hope this can be helpful to someone else ..

Riddler ?

11 Feb 2011, 11:12 AM
Can't it be as simple as prefixing it with "tel:" to make phone calls and "mailto:" to send emails? If we can use a prefix like "web:" to make links load in the mobile browser that will be terrific and more consistent!

6 Dec 2011, 4:46 AM
Did you find any other solutions ? I am using online PhoneGap Build, so I would like to avoid changing iPhone SDK files :)


6 Dec 2011, 4:59 AM
No unfortunately not ...

6 Dec 2011, 5:06 AM
I manage to open Safari if I had the website in the .plist file first, using the key ExternalHosts... Annoying...