用于从非默认iOS浏览器在Safari中打开iPhone的JavaScript [英] JavaScript for iPhone to open in Safari from non-default iOS browser

查看:680
本文介绍了用于从非默认iOS浏览器在Safari中打开iPhone的JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在移动版Safari中打开的googlechrome://www.lego.com会切换到Google Chrome iOS应用以打开网址。这允许像下面那样的scriptlet,它允许您在Google Chrome iOS应用中打开当前页面,从移动Safari切换:

 (()的函数%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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆