用于从非默认iOS浏览器在Safari中打开iPhone的JavaScript [英] JavaScript for iPhone to open in Safari from non-default iOS browser
问题描述
(()的函数%7Bif(document.location.href.indexOf( 'HTTP')=== 0)document.location.href = document.location.href.replace(/%5Ehttp / 'googlechrome'); %7D)();
我的问题是,可以反过来做吗?我试过safari://www.lego.com,它只是一个无效的网址。您是否可以制作一个脚本,将从 Google Chrome 切换到移动版Safari以打开当前页面。
答案是肯定的。礼貌或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);
执行该代码,转到您的主屏幕,重新打开Chrome,还有一个神奇的后退按钮可以回到Safari。这可能不是你想要的,但它确实有用......扭结。
祝你好运!
更新:
这是截图:
链接(对不起,我没有足够的声誉把它放在帖子中): http://i.stack.imgur.com/OR175.jpg
更新
似乎执行此操作的功能已损坏。谢谢!
"googlechrome://www.lego.com" opened in mobile Safari will switch to Google Chrome iOS app to open the 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:
(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. Can you make a scriptlet which switches from Google Chrome to mobile Safari to open the current page.
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:
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. 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
Update:
It seems that the functionality to do this has broken. Thank you!
这篇关于用于从非默认iOS浏览器在Safari中打开iPhone的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!