GitHub Action commited on
Commit
367ef98
·
1 Parent(s): 9758946

Sync ling-space changes from GitHub commit d5e32ed

Browse files
Files changed (1) hide show
  1. static/app.html +5 -9
static/app.html CHANGED
@@ -26,10 +26,14 @@
26
  console.log(`[I18n] Language set to: ${lang}`);
27
 
28
  if (reload) {
 
 
 
 
29
  // Update URL to reflect language or just reload
30
  const url = new URL(window.location);
31
  url.searchParams.set(SpaceApp.URL_PARAM_LANG, lang);
32
- window.location.href = url.toString();
33
  }
34
  },
35
 
@@ -326,11 +330,3 @@
326
  console.info('Iframe Error Poller Script Loaded');
327
  })();
328
  </script>
329
- <script>
330
- // 我们当前存活在一个 iframe 里面。观察 document, window, window.parent。
331
-
332
- console.log('document is', document);
333
- console.log('window is ', window);
334
- console.log('window parent is ', window.parent);
335
-
336
- </script>
 
26
  console.log(`[I18n] Language set to: ${lang}`);
27
 
28
  if (reload) {
29
+ // If we are in an iframe, we want to change the top-level URL
30
+ // Otherwise, just change the current window URL. using window.top
31
+ const isInIframe = window.self !== window.top;
32
+ const targetWindow = isInIframe ? window.top : window;
33
  // Update URL to reflect language or just reload
34
  const url = new URL(window.location);
35
  url.searchParams.set(SpaceApp.URL_PARAM_LANG, lang);
36
+ targetWindow.location.href = url.toString();
37
  }
38
  },
39
 
 
330
  console.info('Iframe Error Poller Script Loaded');
331
  })();
332
  </script>