Jacob Raccuia
Jacob Raccuia

Reputation: 1686

why does this code <a target="Open in New Window"> opens in a new window?

I forgot to replace the words "Open in a New Window" with _blank when testing a system and I found that even though the html looks as such, it still opens in a new tab.

<a target="Open in New Window" href="http://google.com">Google</a>

here is a jsfiddle to see for yourself!

note: I'm using latest Firefox on OSX. I also tested in Chrome in which case it also works.

Why does this happen?

Upvotes: 0

Views: 78

Answers (3)

DonJuma
DonJuma

Reputation: 2094

As per the following specification, a target parameter that doesn't exist has a default effect of opening in a new window.

http://www.w3.org/TR/html5/browsers.html#valid-browsing-context-name-or-keyword

The specification also lists out the behavior of all the other possibilities.

Upvotes: 1

allen1
allen1

Reputation: 744

This happens because if the target is set, it will always open up in the window identified by what you put in the target. So, you're opening it up in a new window identified by "Open in New Window".

Upvotes: 0

GillesC
GillesC

Reputation: 10874

http://www.w3schools.com/tags/att_a_target.asp

Because if it's not a known parameter it takes it as a window name and create a new window as none of that name are available.

Upvotes: 2

Related Questions