Live data from Hacker News

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

kyrylo.org

181–190 of 203 posts

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

#181
post #155

Earlier quoted context omitted.

If front-end devs would stop reinventing things using JS that can be done in CSS, I'd be so happy.

Why?

Because the JS version will likely take more resources and probably end up being done wrong anyways.

I just don't get why front-end devs feel the need to reinvent everything.

I mean, for fuck's sake, front-end devs for some reason have a fascination with reinventing fucking SCROLLING. And 100% of the time, it either doesn't work, has less functionality than what was built-in, or is annoying for the simple fact that it changes an expected behavior.

If I click my scroll wheel once, and the page keeps scrolling and the scrolling slowly comes to a stop as if it had momentum, that's a bug, not a feature. Stop wasting time deliberately writing bugs.

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

#182
post #157

Earlier quoted context omitted.

Another weird case: In Google's server-side JS environment Apps Script, function names that end with _ are treated as private functions that cannot be called directly by the user or enumerated. 1. https://developers.google.com/apps-script/guides/html/commun...

In the Python world I was in, trailing underscores is used to work around the ban on reserved words. The language grabs some of the best names for itself! So a variable that really ought to be named `class` you name `class_`.

In java usually clazz

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

#183

I went digging in W3C archives to find relevant discussions. There are 4 reserved target names: _blank, _parent, _self, _top. - 1995 Sept https://web.archive.org/web/19990202141025/http://home.mcom.... Netscape Navigator 2.0a2 release notes including rollout of TARGET. - 1995 Sept https://lists.w3.org/Archives/Public/www-html/1995Sep/0034.h... First definition of them; spec text provided by "the Netscape Navigator ma…

Years ago I discovered that Yahoo Fantasy Football would open links to each player profile in its own window/tab, even if I clicked on the same player over and over. I dug in and found that they were using target="playername-idnum".

I've used it everywhere ever since when most people would just use _blank. If you're like me and ever go down and article, clicking all of the links to open in new tabs to look at later then you're welcome...I saved you a few wasted tabs when you clicked on the same link more than once.

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

#184

Earlier quoted context omitted.

Making it a dollar sign would cause countless bugs for people who generate HTML using templating languages whose variables are indicated by dollar sign. From time to time, someone would add target="$blank" to a templates, forgetting that the $ must be escaped to be literal. They might have to resort to predefining a reserved variable called blank, whose value is "$blank". :) Similar reasoning applies to most other sp…

Your reason is unlikely to be a cause. The _ comes from the W3C in 1995 well before JavaScript was commonly used for templating HTML. Scripting has used $ for variables for a long time: I think the most relevant history line for $variable is PHP comes from Perl comes from shell scripts. I also remember finding $ ugly on Vax. There were a huge variety of templating syntaxes for server side and HTML generation was virt…

Shell script here documents can generate HTML:

  cat 
    ...
    
A form of CGI existed as far back as 1993 on the NCSA web server.

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

#185
Perhaps for the same reason "World wide web inventor admits forward slashes 'a mistake'" [0]I wonder what the cumulative years / time wasted writing '://' or the amount of energy which could have been saved computing it would be?

[0] https://economictimes.indiatimes.com/tech/internet/world-wid...

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

#186

Why did we move away from this model of web development? If I remember back that far, it seems like fairly soon after this was when the meta starting telling us that frames were bad, and using was bad, etc. It all honestly seemed a lot easier than what has come after.

The direct answer to your question is that the idea of "responsive" web design gradually took over when smartphones became popular. People liked the idea of not needing to create a separate mobile version of their frontend, and instead simply adjusting the styling and structure of the page in response to the size of the viewport. Tables were bad at this because you couldn't use CSS to arbitrarily move around the way…

[deleted]

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

#187

Earlier quoted context omitted.

There probably was no discussion about it. Back then you didn't have tens of managers looking to add their input to a project, so if you came up with something, you could just demo it, and unless someone had a very specific reason to reject it, nobody would. I'm not saying this is the answer, but it very well could be that whoever wrote the function that handles this decided on an underscore and nobody ever even ques…

and really this should be the path: define a new convention, then standardized after - if it's needed (spoiler: probably not going to need it). This is definitely not perfect; it's incredibly painful to retrofit standards, but I'm not convinced it's less work than creating a bunch of standards no one needs.

Please don’t. In theory this works for some things. But when you have multiple implementations of the browser doing different things given the same code it is a nightmare. A solid well defined spec is necessary in that case.

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

#188

Earlier quoted context omitted.

and really this should be the path: define a new convention, then standardized after - if it's needed (spoiler: probably not going to need it). This is definitely not perfect; it's incredibly painful to retrofit standards, but I'm not convinced it's less work than creating a bunch of standards no one needs.

Please don’t. In theory this works for some things. But when you have multiple implementations of the browser doing different things given the same code it is a nightmare. A solid well defined spec is necessary in that case.

In which case, the need for the spec should be obvious from the onset. Nobody though that html would be used the way it was used today. But we now know the same things as they knew back then, meaning that we do not know nothing, we don't know what will be used and need interoperability. Also, specs means nothing if each implementation can and will do whatever they want (ie. Chrome vs Firefox vs Edge)

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

#189
post #105

Earlier quoted context omitted.

This is a direct descendant of ActionScript. It introduced the convention of Instance._getter and Instance.__private.

That looks like ActionScript 2, so the javascript convention was actually well in place by then. I can't speak confidently about the late 90s, but I wouldn't be surprised if it predated Actionscript 1 as well. But doesn't it all trace back to C conventions anyways?

[deleted]

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

#190
post #96
post #37

Earlier quoted context omitted.

Also worth noting that "_new" is NOT a reserved keyword, but it is sometimes mistakenly used instead of "_blank". Which can lead to funny behavior if you are visiting 2 or more sites making this mistake, as the links could then start opening in windows that were initially opened by the other site. Or least that's how it was back in the days of popup windows, before tabs and popup blockers became the norm.

Not just weird behavior, but possible security issues. Browsers now automatically add a rel="noopener" to links that target _blank to prevent the opened site from gaining full access to your javascript object. Targeting _new does not do this unless you explicity add the rel="noopener" yourself. https://github.com/whatwg/html/issues/4078 https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes...

Nobody gets "full access" to your "javascript object"—whatever that even means; pages from different origins will still run into exceptions when trying to diddle the opener. There is a small, well-known set of (safe) properties that are excluded from the restrictions—like location. But the noopener behavior, by making opener null, does stop other pages from setting even opener.location, which could ordinarily be used to programmatically send the user to another page.
Post reply on HN