Hide div in a Custom Tab opened from a Trusted Web Activity

空扰寡人 提交于 2021-01-29 05:10:34

问题


I have an Android app which uses Trusted Web Activity with an external link. When clicking link it opens in an in-app browser (Custom Tabs). I want hide a div in that Custom Tabs page, but I want to show that div when the site opens in Chrome. Is it possible? The div is like below.

<div id="something" class="something"><a class="btn btn-primary" href="somelink">text</a></div>


回答1:


Assuming the developer controls both sites involved, if the Trusted Web Activity is opening https://siteA.com and https://siteB.com is opened from a link on site A and you want to hide a div onlnye when siteA opens siteB.

You could link to https://siteB.com?hideDiv=true. siteA can append the extra parameter only when inside a Trusted Web Activity. siteB checks if the parameters exists and hides the dive if it is present.

Another alternative is checking document.referrer in JavaScript and checking if it matches https://siteA.com.



来源:https://stackoverflow.com/questions/61517599/hide-div-in-a-custom-tab-opened-from-a-trusted-web-activity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!