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?
CodePudding user response:
try
window.open("https://translate.google.com", "_self");
_self
open in current tab
_blank
open in new tab
CodePudding user response:
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")