File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 >
You can’t perform that action at this time.
0 commit comments