Ad view: reliable exit on mobile/dApp browsers

window.close() is blocked in mobile and in-app wallet (dApp) browsers, which left
users stuck on the ad-view tab. Made "Back to dashboard" the primary action, and
"Close tab" now falls back to navigating to /my#earn when the browser refuses to
close the tab.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-08 07:17:39 -05:00
parent 8d9f56f68a
commit 50c0bd1aa7
2 changed files with 9 additions and 4 deletions
+6 -1
View File
@@ -82,7 +82,12 @@
}
$('vClose').addEventListener('click', () => {
window.close();
setMsg('You can close this tab now.');
// window.close() is blocked in mobile and in-app (wallet dApp) browsers. If
// the tab is still here a moment later, take them back to the dashboard so
// they are never stuck on a tab they can't close.
setTimeout(() => {
if (!window.closed) { setMsg('Taking you back to your dashboard…'); location.href = '/my#earn'; }
}, 400);
});
(async () => {
const info = await j('/api/my/viewinfo?token=' + token);