JS - Mobile - Open Safari from any browser

2019-01-15 17:26发布

问题:

Since Apple allow use camera in Safari (Mobile). We can do a lot things, but sharing them is hard. You can not open a website in Safari from another browser directly (Chrome, FacebookBrowser, MessengerBrowser, SkypeBrowser...).

Safari have 4 URL Schemes:

(HTTP) — http://websiteurl

(HTTPS) — https://websiteurl

x-web-search://

(FTP) — ftp://locationtofileonftpserver

If you use <a href="https://somewebsite"></a> or window.open("http://somewebsite"). It always use current browser to open url.

x-web-search://?[query] - It will open Safari but using Google and search somthing in query

Still only ftp left. If you want to open website (HTTPS) in Safari. you will need a bridge html file in your ftp server and open it like as:

ftp://000.000.000.000/bridge.html Now, the only thing "bridge.html" does is

<script> window.open("https://yoururl", "_self"); </script>

And Safari will open your website from any browser

You can add params URL to your ftp link (ftp://000.000.000.000/bridge.html?url=https://someURL) Catch it in bridge.html after window.open

Hope it help. Good luck.