Live data from Hacker News

Why does target="_blank" have an underscore in front? (2024)

kyrylo.org

41–50 of 203 posts

Re: Why does target="_blank" have an underscore in front? (2024)

#43
post #18

I was expecting this post to explain why it's an underscore specifically, as opposed to a dollar sign, an asterisk, a caret, a tilde or some other special character. I can only assume it's a holdover of languages like C where the standard library has some reserved names that start with an underscore. https://devblogs.microsoft.com/oldnewthing/20230109-00/?p=10...

[deleted]

Re: Why does target="_blank" have an underscore in front? (2024)

#44
> developers needed a way to explicitly tell the browser to open the link in a new tab, free of frame semantics

First, it doesn't say why an underscore does that, because you could totally have underscores in frame names. My guess as others here is that the underscore prefix dates back from reserved names in C and C++. IIRC the reserved names also included "_self" (even if it was the default), "_parent" (to go up a level in the frame hierarchy) and "_top" to replace the whole page.

Second, at the time it was clearly not "open the link in a new tab" but rather in a "new window". IE was the most used browser back then, by a large proportion, and it didn't supports tabs at all.

Re: Why does target="_blank" have an underscore in front? (2024)

#45
post #11

Shower thought: ` ` should transfer a link in a desktop into my phone. Same goes for `target="_desktop"` but in the opposite direction.

Should it really be up to the Website designer to decide? On Firefox I have the "Send Link to Device" context action that allow me to open a link on my Phone or Desktop.

I would imagine that it'd be best done with the "share" API that already exists.

A website designer then might say "share this url on click" and the browser takes over and/or defers to the OS.

Now, the share() [https://developer.mozilla.org/en-US/docs/Web/API/Navigator/s...] falls short in passing along context for login (e.g. cookies) so I'd imagine that this would either be part of the browser, or something the share() api could extend on, though I'd be unconfortable about the security implications of the latter.

The share() also falls short on desktop in my experience. AFAIK, firefox (on linux?) doesn't even have the share() API available.

The browser now already registers itself as a target to share web urls. It does this already (on my mobile devices at least) as "Open URL in Firefox" for example.

It should and could also add a target to share web urls, but call it "Send to device". Firefox for Android used to have this and it was awesome. But mozilla somehow dropped it. (There was a long thread on a bug report about exactly this, but I cannot find it).

Also, when I choose that option, it'd not just send the url along, but could also send any cookies or even localstorage and other data along. That way I'd be logged in.

That last part would be part of the "send to " feature, in Firefox called "firefox sync" and possibly be configurable from there to opt out of sending session or other data along.

Point is: there's no need for extra "target=" hackery, we already have all the tech in place to send links to devices. Instead, we'd have to convince browser builders to improve this tech and the UX of it.

Re: Why does target="_blank" have an underscore in front? (2024)

#47
post #38

Earlier quoted context omitted.

> The title of the post isn't asking *HN users* a question

So everyone else then? Sounds like someone is just grumpy today.

The headline of the article is a rhetorical question, one that the article itself then answers in detail. It's a very common device.

Re: Why does target="_blank" have an underscore in front? (2024)

#48
post #23

Minor nitpick: browsers used _blank as a special directive to open the link in a new “window”, not a tab. Browsers didn’t have tabs back then, well other than Opera 4.x which was a paid software which never cracked 3% marketshare.

Author here — thank you! You're absolutely right, and I've corrected it!

Another nitpick: the attribute was called name, not id.

https://www.w3.org/TR/html401/present/frames.html#h-16.3

Re: Why does target="_blank" have an underscore in front? (2024)

#49

I think it's funny that Mozilla says not to use frames anymore, they work just fine on modern browsers...

You mean [the mdn docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fr...)? Looks like classic deprecation to me: they'll still 'work', you just shouldn't use them. In the same way that tables-for-layout still 'works', but you shouldn't actually do that.

Re: Why does target="_blank" have an underscore in front? (2024)

#50
post #41

So basically It’s an “_blank” because it is.. Author’s description is, “because if it wasn’t _blank.. it wouldn’t open a new tab.” Reminds me of some university professors I had.

"I dunno...is magic" (engineering Calculus II GTA, Virginia Tech, 2006)
Post reply on HN