Scenario
Open new tab (http://example.com/slave). Enter into console:
window.name = "example-slave"
Open new tab (http://example.com/master). Add HTML:
<a href="http://example.com" target="example-slave">Click me!</a>
Expected effect
Added link should open example.com in first tab (example-slave).
Current effect
Added link is opening new window, and then every additional click opens example.com in this window.
Question
Is it normal? Is there any possibility to get expected effect?
a target=”_blank” Open in New Browser Tab (or Window) The target attribute specifies where the linked document will open when the link is clicked. The default is the current window. If target="_blank" , the linked document will open in a new tab or (on older browsers) a new window.
The Window name property is used for setting or returning the name of a window. It is generally used to modify the name of a window which has been created in the past. It returns a string which represents the name of the window. Syntax: window.name.
Press the Windows logo key + X to see a list of commands and options. Click System. The computer name appears under Computer name, domain, and workgroup settings.
See the specification:
If the given browsing context name is not _blank and there exists a browsing context whose name is the same as the given browsing context name, and the current browsing context is familiar with that browsing context, and the user agent determines that the two browsing contexts are related enough that it is ok if they reach each other, then that browsing context must be the chosen one.
The problem with your scenario is that the two browsing contexts were opened by the user using browser controls. They aren't familiar with each other and are not related at all, so they can't modify each other.
For them to be related you would need to open one from the other using target
or window.open()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With