fix(web): allow user-activated top navigation for custom home iframe (#5955)

The custom home page URL iframe only allows allow-forms/allow-popups/
allow-popups-to-escape-sandbox/allow-scripts, without allow-top-navigation*.
As a result, target="_top" nav/menu links inside the (admin-configured,
trusted) embedded page cannot navigate the top-level window on desktop
browsers, while some mobile browsers still allow it via allow-popups —
causing inconsistent behavior rather than an intended restriction.

Add allow-top-navigation-by-user-activation so user-clicked top-level
links work consistently across devices. This token only permits
user-activated top navigation and does NOT grant same-origin access,
so it avoids the security concern of allow-same-origin.

Co-authored-by: 贺. <kuang@M1.local>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
乾L
2026-07-11 10:52:17 +08:00
committed by GitHub
co-authored by 贺. Claude Opus 4.8
parent 9d1ca545e2
commit ca971413e9
+9 -1
View File
@@ -72,12 +72,20 @@ export function Home() {
if (isUrl) {
return (
<PublicLayout showMainContainer={false}>
{/*
allow-top-navigation-by-user-activation: the custom home page URL is
admin-configured (trusted); this lets its target="_top" nav/menu links
navigate the top-level window on user click. The default sandbox blocks
this on desktop, while some mobile browsers allow it via allow-popups,
causing inconsistent behavior. This token only permits user-activated
top-level navigation and does NOT grant same-origin access.
*/}
<iframe
ref={iframeRef}
src={content}
className='h-screen w-full border-none'
title={t('Custom Home Page')}
sandbox='allow-forms allow-popups allow-popups-to-escape-sandbox allow-scripts'
sandbox='allow-forms allow-popups allow-popups-to-escape-sandbox allow-scripts allow-top-navigation-by-user-activation'
onLoad={syncIframePreferences}
/>
</PublicLayout>