[英]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.