问题
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