Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is possible to use target and window.name?

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?

like image 400
marverix Avatar asked Jul 03 '15 07:07

marverix


People also ask

What is window target?

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.

What does window name mean?

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.

How do I find out my windows 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.


1 Answers

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().

like image 197
Quentin Avatar answered Oct 15 '22 19:10

Quentin