Skip to content

Commit cb1d6d1

Browse files
committed
Update exernal links.
1 parent c3a885e commit cb1d6d1

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

src/layouts/Layout.astro

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,26 @@ if ("serviceWorker" in navigator) {
118118
});
119119
}
120120

121-
if (window.matchMedia('(display-mode: standalone)').matches) {
122-
document.addEventListener('click', function (e: any) {
123-
const anchor = e.target.closest('a');
124-
125-
if (!anchor || !anchor.href) return;
126-
127-
const origin = window.location.origin;
128-
const href = anchor.getAttribute('href');
129-
130-
if (
131-
href.startsWith('#') ||
132-
href.startsWith('/') ||
133-
href.startsWith(origin)
134-
) {
135-
return;
136-
}
137-
138-
e.preventDefault();
139-
140-
alert('External links are available only via website.');
141-
});
142-
}
121+
document.addEventListener('DOMContentLoaded', () => {
122+
if (window.matchMedia('(display-mode: standalone)').matches) {
123+
document.addEventListener('click', function (e:any) {
124+
const anchor = e.target.closest('a');
125+
if (!anchor || !anchor.href) return;
126+
127+
const origin = window.location.origin;
128+
const href = anchor.getAttribute('href');
129+
130+
if (
131+
href.startsWith('#') ||
132+
href.startsWith('/') ||
133+
href.startsWith(origin)
134+
) {
135+
return;
136+
}
137+
138+
e.preventDefault();
139+
alert('External links are available only via website.');
140+
}, { passive: false });
141+
}
142+
});
143143
</script>

0 commit comments

Comments
 (0)