如何从应用程序中的网页启动移动浏览器



我正在一个应用程序内部的移动网站上工作。我无法访问应用程序本身。有几个链接,我的客户希望从应用程序中的网站启动,并在移动浏览器打开。有办法做到这一点吗?任何帮助都会非常感激。谢谢。

从你的问题来看,我不知道你想要什么平台,所以这里是你标记的两个平台的解决方案。在Android上你可以使用这个(http://developer.android.com/reference/android/content/Intent.html):

)
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://urlhere.com"));
startActivity(browserIntent);

在iOS上你可以使用这个(http://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/openURL:):

)
[[UIApplication sharedApplication] openURL:[NSURL urlWithString:@"http://urlhere.com"]];

我不确定Android,但在iOS上,你需要访问应用程序的源代码才能覆盖

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

[[UIApplication sharedApplication] openURL:url];
如果请求的URL应该在MobileSafari中打开。

"如果您只需要知道您的查看器正在使用哪个设备,您可以使用服务器端检测,如handsetdetection。服务器端检测的优点是,您可以根据设备使用不同的模板或布局。"

最新更新