简体   繁体   English

Android Chrome浏览器“自定义”标签-在新标签+ Postmessage中打开链接

[英]Android Chrome Custom Tabs - Open link in new tab + Postmessage

I've got two web pages. 我有两个网页。 The first one opens the second one in a new tab. 第一个在新选项卡中打开第二个。 They're talking to each other with JavaScript's postMessage. 他们正在用JavaScript的postMessage互相交谈。 This setup works fine in every browser (desktop/mobile). 此设置在每种浏览器(台式机/移动设备)中均能正常运行。

When I try to simulate the same behavior using Chrome Custom Tabs on Android the second page is opened in the same layout instead in a new one. 当我尝试使用Android上的Chrome自定义标签来模拟相同的行为时,第二页将以相同的布局打开,而不是以新的布局打开。 As a result I can no longer use postMessage. 结果,我不能再使用postMessage。

How to force links inside a custom tab to be opened in a new custom tab and preserve postMessage capabilities? 如何强制自定义标签内的链接在新的自定义标签中打开并保留postMessage功能?

There is no way to create another custom tab from web contents. 无法从Web内容创建另一个自定义选项卡。 This is because we want to maintain a quick way to return to the app that opened the tab. 这是因为我们希望保持一种快速的方法来返回打开选项卡的应用程序。

On the other hand, I cannot recall the logic checking for tab type/visibility in postMessage. 另一方面,我无法回忆起postMessage中检查选项卡类型/可见性的逻辑。 Sounds like a bug. 听起来像个臭虫。

A bug with detailed reproducer would help a lot, please use the "this template" link in README.md: https://github.com/GoogleChrome/custom-tabs-client 具有详细复制器的错误会有所帮助,请使用README.md中的“此模板”链接: https : //github.com/GoogleChrome/custom-tabs-client

Thanks! 谢谢!

Egor, thanks for your help! 埃格,谢谢您的帮助!

The problem has been solved by installing the newest version of Chrome for Android. 通过安装适用于Android的最新版本的Chrome已解决了该问题。

Using Chrome Custom Tabs with Chrome 48.0.2564.95 window2 loads its content into window1 . 使用Chrome浏览器48.0.2564.95铬自定义选项卡窗口2加载其内容到窗口1。 As of Chrome 49.0.2623.91, window1 's state is preserved and window2 opens on top in the same custom tab, thus hiding window1 . 自Chrome 49.0.2623.91的, 窗口1的状态保存和打开窗口2在同一个自定义选项卡顶部,从而隐藏窗口1。 The postMessage works just fine. postMessage正常工作。 You can see the attached screenshot. 您可以看到所附的屏幕截图。

Android Chrome Debugging with Inspect Devices 使用Inspect设备进行Android Chrome调试

However, a minor bug is still present. 但是,仍然存在一个小错误。 When alert is fired from bottom page window1 , window2 becomes inactive, but remains visible. 当从底部页面window1发出警报时, window2变为非活动状态,但仍可见。 That means the focus is on window1 , but you see window2 's content. 这意味着焦点在window1上 ,但是您看到window2的内容。 I have to move the focus back to window2 manually using the debugger to restore the proper working setup. 我必须使用调试器将焦点手动移回window2 ,以恢复正确的工作设置。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM