Why does target="_blank" have an underscore in front? (2024)
41–50 of 203 posts
Re: Why does target="_blank" have an underscore in front? (2024)
#42Re: Why does target="_blank" have an underscore in front? (2024)
#43I 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...
Re: Why does target="_blank" have an underscore in front? (2024)
#44First, 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)
#45Shower 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.
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)
#46Re: Why does target="_blank" have an underscore in front? (2024)
#47Earlier 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.
Re: Why does target="_blank" have an underscore in front? (2024)
#48Minor 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!
Re: Why does target="_blank" have an underscore in front? (2024)
#49I think it's funny that Mozilla says not to use frames anymore, they work just fine on modern browsers...
Re: Why does target="_blank" have an underscore in front? (2024)
#50So 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.