Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

250
Visualizações
How to open Google translator on a separate tab/window on first run, yet on same separate tab/window on succeeding runs

DeepL (and many other websites) can be opened on a separate tab/window on first run, yet on same separate tab/window on succeeding runs. That is the objective

window.open("https://www.deepl.com/translator", "sameD");

Google Translator cannot, it always open in new tab on succeeding runs, even if the window name is same

window.open("https://translate.google.com", 'sameG');

Why is Google Translator not opening in same tab, does it explicitly disallow it? And how it does that?

Or is there another parameter in window.open to ensure a url can be opened in same separate tab/window?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Not a solution but an explanation for what you are experiencing:

As you already know

window.open("https://translate.google.com", 'sameG');

will open a new window/tab with the name sameG. The call will also return a proxy to the window object of that page.

Also this will set window.opener in the new window to a proxy of the window of the calling window.

Usually calling window.open() again with the same window name will update the previously opened window to navigate to the new URL -- as you do see with the deepl.com example.

But translate.google.com sends a

Cross-Origin-Opener-Policy: same-origin-allow-popups

header! This header is indeed a browser security header and it isolates the browser context of the new window, i.e., the return value of window.open() won't give you any access into the newly opened window and window.opener therein is set to null.

Additionally this loses the reference to the window name sameG and thus subsequent calls to window.open() will again open a new window instead of updating the already opened one.

TL;DR: The Cross-Origin-Opener-Policy is the reason for this.

about 4 years ago · Juan Pablo Isaza Relatório

0

The second parameter window.open() method takes is the target parameter which is the name of the browsing context the resource is being loaded into. You can use the special target keywords, in this case it'll be "_self":

window.open("https://translate.google.com", "_self")
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda