简体   繁体   English

用于从非默认iOS浏览器在Safari中打开iPhone的JavaScript

[英]JavaScript for iPhone to open in Safari from non-default iOS browser

"googlechrome://www.lego.com" opened in mobile Safari will switch to Google Chrome iOS app to open the URL. 在手机Safari中打开的“googlechrome://www.lego.com”将切换到谷歌Chrome iOS应用程序以打开URL。 This allows for scriptlets like the one below, which allows you to open the current page in Google Chrome iOS app, switching from mobile Safari: 这允许像下面那样的scriptlet,它允许您在Google Chrome iOS应用中打开当前页面,从移动Safari切换:

(function()%7Bif(document.location.href.indexOf('http')===0)document.location.href=document.location.href.replace(/%5Ehttp/,'googlechrome');%7D)();

My question is, can the reverse be done? 我的问题是,可以反过来做吗? I tried "safari://www.lego.com", and it is simply an invalid URL. 我试过“safari://www.lego.com”,它只是一个无效的网址。 Can you make a scriptlet which switches from Google Chrome to mobile Safari to open the current page. 您可以制作一个 Google Chrome切换移动版Safari的Scriptlet来打开当前页面。

The answer is yes. 答案是肯定的。 Courtesy or MacStories ( http://www.macstories.net/tutorials/chrome-for-ios-send-a-webpage-back-to-safari-via-bookmarklet/ ), I found this code: 礼貌或MacStories( http://www.macstories.net/tutorials/chrome-for-ios-send-a-webpage-back-to-safari-via-bookmarklet/ ),我发现这段代码:

window.location='googlechrome-x-callback://x-callback-url/open/?url='+encodeURIComponent(location.href)+'&x-source=Safari&x-success='+encodeURIComponent(location.href);

Execute that code, go to your homescreen, reopen Chrome, and there's a magical back button to go back to Safari. 执行该代码,转到主屏幕,重新打开Chrome,然后有一个神奇的后退按钮返回Safari。 This may not be exactly what you want, but it works... Kink of. 这可能不是你想要的,但它的确有效......扭结。

Good luck! 祝好运!

Update: Here's a screenshot: Link (Sorry, I don't have enough reputation to put it right in the post): http://i.stack.imgur.com/OR175.jpg 更新:这是一个截图:链接(对不起,我没有足够的声誉把它放在帖子中): http//i.stack.imgur.com/OR175.jpg

Update: 更新:
It seems that the functionality to do this has broken. 似乎这样做的功能已经破裂。 Thank you! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在非默认浏览器中使用 Electron 打开 URL - Open URL with Electron in non-default Browser 有没有办法在 iPhone/iOS Safari 浏览器中调试 JavaScript? - Is there a way to debug JavaScript in the iPhone/iOS Safari browser? 如何在 Safari 中打开 url 而不是默认浏览器(JavaScript)? - How to open a url in Safari instead of the default browser (JavaScript)? 如何在 javascript 中从任何其他浏览器打开 Safari 浏览器? - How to open Safari browser from any other browser in javascript? iOS-如何在默认浏览器(Safari或Chrome)而非应用内浏览器中打开链接? - iOS - How to open the links in the default browser (Safari or Chrome) instead of the in-app browser? ios PWA 如何在移动默认 safari 上打开外部链接(不在应用浏览器中) - ios PWA How to open external link on mobile default safari(not In app browser) 仅使用HTML或Javascript从Android WebView在默认浏览器中打开链接 - Open link in default browser from Android WebView with HTML or Javascript only Javascript如何在iOS上的Safari中确认浏览器关闭 - Javascript how to confirm browser close in Safari on iOS 使用ui路由器导航到非默认状态 - Navigating to non-default state with ui router 在Iphone,Ipad和使用Safari浏览器 - 提醒“打开myapp” - In Iphone, Ipad and using Safari Browser - An alert “Open with myapp”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM