GithubHelp home page GithubHelp logo

Comments (7)

claviska avatar claviska commented on May 5, 2024

My argument here is sort of hypocritical since this is currently an option in the link panel, but I'll say it anyway. There's a lot of debate about target="_blank" and I was reluctant to even include it in the editor for links (still debating if it should be left in or removed).

I'm reluctant to add this for a few reasons:

  • It's bad UX to mess with the browser's default behavior (although there are some uses for it)
  • It could introduce security risks
  • It's not semantic
  • Perhaps most importantly, users shouldn't have to think about these things

Decisions like this need to be made with more thought than most users will care to give. Letting them check boxes arbitrarily leads to inconsistent results and poor UX for their visitors.

If the designer chooses that this is the preferred behavior for the website, the recommended approach is to use a script to accomplish it. For example, here's a vanilla JS snippet for opening external links in a new tab/window (source):

function externalLinks() {
  for(var c = document.getElementsByTagName("a"), a = 0;a < c.length;a++) {
    var b = c[a];
    b.getAttribute("href") && b.hostname !== location.hostname && (b.target = "_blank")
  }
}

This actually provides more flexibility than a checkbox in the UI, since they can decide if they want to target external links, certain domains, certain media types, or even individual pages. Of course, the flexibility goes to the designer, not the user — but we all know users tend to get creative when they have too much control. 😆

from postleaf.

claviska avatar claviska commented on May 5, 2024

In fact, now that I've actually outlined why target="blank" is such a bad idea, it's more obvious that it needs to be removed from the link panel before it becomes a breaking change in 1.0. 😕

from postleaf.

lukewatts avatar lukewatts commented on May 5, 2024

I don't know. I think a lot of users will want this feature.

Perhaps an option in the .env to enable this feature for more advanced users...or those who really want it?

If plugins become a thing in Postleaf people are just going to implement this themselves anyways at some point.

At least this way you have the opportunity to show a message of reasons perhaps not to do it. Teach people rather than just restrict them.

from postleaf.

lukewatts avatar lukewatts commented on May 5, 2024

I just know when I'm reading articles or documentation and they link to another site or another page of documentation for further reading and it doesn't open a new tab I get really annoyed because I lose where I was. (I'm a 100 tabs open at once kinda guy)

from postleaf.

lukewatts avatar lukewatts commented on May 5, 2024

If not the target="blank" attribute then at least the ability to add additional classes or data-attributes so people can target links with JS as they want.

from postleaf.

claviska avatar claviska commented on May 5, 2024

Teach people rather than just restrict them.

The people that need to be taught about things like this are web designers who don't know any better despite that being their job. End users don't care and will misuse things like this because they want something a certain way, and that negatively effects every visitor to their site.

I know I'm very opinionated and often anal about certain things. I believe the web designer should decide how things look, feel, and behave. These are critical design decisions, not ones that most users are capable of making without compromising their visitors' UX.

I just know when I'm reading articles or documentation and they link to another site or another page of documentation for further reading and it doesn't open a new tab I get really annoyed because I lose where I was.

True. On the other hand, I religiously use CMD+click to open links in a new window. When I expect a link to open on the same page and it doesn't, I too get annoyed. 🤷‍♂️

If not the target="blank" attribute then at least additional classes or data-attributes so people can target links with JS as they want.

Designers can target links with infinite flexibility using JavaScript, but this forces more thought and that's a good thing. It changes one's thinking from "I want this random link to behave differently for whatever reason" to "what makes a link unique in such a way that it should be opened in a new window?"

And that leads to a consistent design solution that end users don't ever have to think about 😄

from postleaf.

claviska avatar claviska commented on May 5, 2024

I've brain-dumped even more into a blog post since I know a lot of people will ask about this.

This is the type of decision that separates Postleaf from every other platform: the attention to detail, the focus on users and visitors, and the ability for designers to make decisions they're trained to make.

Lots of emotions will be stirred, I'm sure: postleaf.org/dont-open-links-in-a-new-window

from postleaf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.