什么是Mobile Safari的自定义urlscheme?

iOS URL Schemes允许网站启动应用程序,如下所示:

  • twitter://timeline启动Twitter
  • googlechrome://google.com启动Chrome
  • fb://root启动Facebook
  • ______________启动Safari? (不是http:// ,因为Safari不会从UIWebView启动)

什么自定义urlscheme触发Safari启动(甚至从另一个应用程序的UIWebView )?

澄清,我不是在寻找[[UIApplication sharedApplication] openURL: request.URL];

相反,我正在寻找一个网站如何允许用户从另一个应用程序(Google Chrome,Twitter等)的UIWebView中启动Mobile Safari。

popup打开其他应用程序的HTML链接示例:

 <a href="twitter://timeline">Open Twitter</a> <a href="googlechrome://google.com">Open site in Chrome</a> <a href="fb://root">Open Facebook</a> 

我正在寻找类似这些非工作例子的东西:

 <a href="safari://google.com">Open Safari [Doesn't work]</a> <a href="webkit://google.com">Open Webkit [Doesn't work]</a> 

这是一个相同的jsFiddle : http : //jsfiddle.net/gXLjF/9/embedded/result/

尝试在iOS谷歌浏览器中打开此url ,然后使用链接打开Safari。

至于任何网页浏览器, http://someurl.comhttps://someurl.com

没有Safari URLscheme。 如果你创build一个并在你的html中使用它,你可以检查它。

实现UIWebViewDelegate方法webView:shouldStartLoadWithRequest:navigationType: 对于您要分stream至移动Safari的请求返回“NO”。 使用请求的URL调用UIApplication openURL

像这样的东西:

 - (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { // all clicked links! if ( navigationType == UIWebViewNavigationTypeLinkClicked ) { [[UIApplication sharedApplication] openURL: request.URL]; return NO; } // or, custom URL scheme! if ( [request.URL.scheme isEqualToString: @"my-open-in-safari"] ) { // remap back to http. untested! NSURL* url = [NSURL URLWithString: [request.URL.absoluteString stringByReplacingOccurrencesOfString: @"my-open-in-safari" withString: @"http" ]]; [[UIApplication sharedApplication] openURL: url]; return NO; } return YES; }