Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Mobile Safari from a Link in a WebView

Tags:

ios

webview

Is there a URI scheme to open Mobile Safari to a specific URL?

e.g.,

<a href="safari://open_url/?url=google.com">Open Google in Safari</a>
like image 654
Kirk Ouimet Avatar asked Apr 30 '12 20:04

Kirk Ouimet


People also ask

Does Safari use WebView?

A WebView uses webkit engine to render html which is what safari also uses.

What is Mobile Safari WebView?

WKWebView is an API that helps render web pages in iOS and macOS apps.

How do I open a link in an app instead of Safari?

Go to settings, apps, then find that app on your list, click it, part way down that page there an option called opens by default, select that.

Does WebView work on iOS?

WebView can be defined as an object which can display the interactive web content and load HTML strings within the iOS application for an in-app browser. It is an instance of the WKWebView class, which inherits the UIView class.


2 Answers

Update: So, as of iOS 6.0.2, there is still isn't a URL scheme specific to MobileSafari (see below). However, Federico Viticci has posted an interesting hack that will allow you to call Safari from Chrome for iOS. It's not as functional as a Chrome-to-Safari bookmarklet, but it does show it's possible to launch MobileSafari from Chrome for iOS.

Original Answer: It turns out you can't open a link in Safari using just a URI scheme. Hyperlinks in other apps can be opened in safari using openURL (see other answers), but there is no scheme for MobileSafari itself (which you would need if you were to open a link in Safari using a hyperlink in Chrome or Opera for iOS).

Google Chrome has the following two URI schemes: googlechrome:// and googlechromes:// (for HTTPS) that work just as any other app-specific scheme (such as dayone://, things://, or sms://).

like image 146
Dave Avatar answered Jan 19 '23 01:01

Dave


Try this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com/"]];
like image 39
Simon Goldeen Avatar answered Jan 19 '23 01:01

Simon Goldeen