Log in

View Full Version : target="_whatever" - To use or not to use



naiani
08-17-2007, 03:50 PM
Good morning everyone!

I'm making some changes to the website I previously posted, and I have a question. I changed my DOCTYPE to HTML Strict after Twey's tip (which is really valid). But I now have a problem with some of the links, because of the target attribute. I googled a solution for it using CSS but apparently it doesn't exist, what I think is pretty logical. But what am I gonna do about the links to external pages that shouldn't open in the _self window, but in a _blank one (tab or new window)? I know that this should be the user's decision, but what to do when the prospect users probably won't care about making a decision, they'll just click and expect the new website to open in a new window/tab? Should I use target="_blank" anyway? Should I use JavaScript for a workaround?
I don't think using a website should be a philosophical decision that would change my entire life forever, but I also want to validate my stuff in a DOCTYPE that is not "deprecated".

I need advice again. What do you do in this case? Thanks!

Spiritvn
08-17-2007, 03:56 PM
When you have not formatted the target, it will be opened in the same window for the default, you can use the target="_blank" for that link and it open the link in the new window for the default.

Within my css knowledge, CSS doesn't provide you the solution for all links. You should use javascript ^^

jscheuer1
08-17-2007, 04:11 PM
The target attribute has been taken away (deprecated) in 4.01 strict and above. The best solution that I have seen is to use javascript:


<a href="some.htm" onclick="window.open(this.href,'_blank');return false;">Link</a>

This is obviously far from ideal, as many folks surf with javascript disabled or in browsers that just don't have javascript at all.

I seriously doubt that the target attribute will cease being supported in the real world though (read: in browsers). And, to get your page to validate, you could use target and the transitional DOCTYPE:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">

You can do both, use the transitional DOCTYPE and:


<a href="some.htm" target="_blank" onclick="window.open(this.href,this.target);return false;">Link</a>

That way, pretty much all of your bases are covered.

However, people surfing without javascript generally are looking for a tamed web experience that goes along very predictable lines. Like, when they click on a link, they want the current page to change to it, etc. So, using the strict DOCTYPE and no target attribute with a javascript like in my first example might be the right way to go.

Using this philosophy (with the strict DOCTYPE) would tend to be the best way to 'future proof' your pages, at least in theory.

Personally, I think target will continue to be supported by browsers for a very, very long time though, regardless of what the w3c does.

Twey
08-17-2007, 04:27 PM
Personally, I think target will continue to be supported by browsers for a very, very long time though, regardless of what the w3c does.That's really besides the point.

naiani, the reasoning behind not including target was that opening windows is bad design practice from an accessibility point of view anyway. If you really must, use Javascript, but it's almost always better to let the user choose whether a link should open in a new window/tab or not.

jscheuer1
08-17-2007, 05:03 PM
I think the point is whether or not target is supported. In my opinion, this is one of the several cases where standards are behind practice, and not leading it. I admit it can be overused. However, with any decent browser, we already have the choice of where things open, regardless of what HTML code is employed.

Twey
08-17-2007, 05:18 PM
I think the point is whether or not target is supported.No, the discussion was to do with the standards in this case.
However, with any decent browser, we already have the choice of where things open, regardless of what HTML code is employed.Then why not simply ignore the existence of target? The user will invariably know better than the designer which pages they want opened in separate windows or tabs; surely it makes more sense to present them with a consistent behaviour and allow them to override it.

naiani
08-17-2007, 05:29 PM
I agree with the reasons for it to be avoided/deprecated. However, I try to analyze the situations also from the DUMMY user point of view. Because unless the user is a nerd or needs/learned it for accessibility/usability improvement, nobody else actually changes the default configuration for this kind of thing. How many dummies do you know? By dummy I mean everybody who uses a computer for the most common stuff (typing/internet/games) and doesn't spend one's time reading ALA or PIE or anything similar to this, but wants to read the latest Hollywood gossip or play Counter Strike (or whatever game is cool these days).
After thinking about how many dummies you know/have/had to work for, think about how many NOT dummy users you know.
I'm not saying that dummy == dumb, I'm saying that they're just not interested in learning these details, because they don't think they need them (and they probably don't). Therefore, if they're used to developers using target="_blank" and they like it (because I don't think people actually want to CHANGE the website they're visiting when they click on a link, they want to check the given reference and keep looking at the main one), if the links suddenly start to "decide" that they want to leave this page and go to another one, I'm pretty sure they won't like it...

That's what makes me a little bit worried about this question (and about many other tech issues that go through the same problem). Anyway, I'm gonna use the JS solution. Thank you all!

jscheuer1
08-17-2007, 05:31 PM
As to if this is a discussion of standards or of support is in the eye of the beholder.

I think it is reasonable to have off site links open in a new window, and on site links open in the same window. Also reasonable is having a truly separate portion of a site open in a new window. If the user doesn't like it, they can take control, but that is no reason not to allow the designer the ability to organize the flow of the links logically as he or she sees fit to optimize the experience for the typical user.

I have many times lost track of a site I was interested in because all of its off site links opened in the same window. I know, I could use the back button, but sometimes that doesn't work, and history can be difficult to negotiate. In any case, it can be quite a bit of a bother compared to having the site still being there.

I am grateful that the forum opens links in a new tab/window. Otherwise, I might never get to help anyone.

naiani
08-17-2007, 05:34 PM
I have many times lost track of a site I was interested in because all of its off site links opened in the same window. I know, I could use the back button, but sometimes that doesn't work, and history can be difficult to negotiate. In any case, it can be quite a bit of a bother compared to having the site still being there.
That's exactly my point.

Twey
08-17-2007, 06:17 PM
unless the user is a nerd or needs/learned it for accessibility/usability improvement, nobody else actually changes the default configuration for this kind of thing.
I have many times lost track of a site I was interested in because all of its off site links opened in the same window. I know, I could use the back button, but sometimes that doesn't work, and history can be difficult to negotiate.For me, it's a case of holding down ctrl or middle-clicking the link -- no reconfiguration required.

jscheuer1
08-17-2007, 06:23 PM
For me, it's a case of holding down ctrl or middle-clicking the link -- no reconfiguration required.

Face it Twey, we're both (whatever else we may also be) nerds. Our perspective can never be that of the typical user. We can only, at best, imagine it. I try to think back to the days when I first got a computer, and the days when I first got a browser, but even that isn't what today's novices/non-techies experience.

naiani
08-17-2007, 06:32 PM
Face it Twey, we're both (whatever else we may also be) nerds. Our perspective can never be that of the typical user. We can only, at best, imagine it. I try to think back to the days when I first got a computer, and the days when I first got a browser, but even that isn't what today's novices/non-techies experience.
Exactly. When I first got a computer, I was so curious to learn everything about it. My nerd soul was starting to develop. It was Windows 3.1, I think. I learned everything very fast, and soon everybody came to me to ask tech questions (and I was 11 or younger, I think). My younger brother, however, started to bother me to share the computer when he was 16 or something (and I was 18), and now, 4 years later, his knowledge is restricted to games when they work (when they don't, I have to fix the problem), MSN, P2P and **** movies/games. He doesn't know that Shift+left click, or middle click, open the link in a new tab/window. For him, links just open in a new tab/window. It's all he wants to know. And I'm not even gonna start talking about my mother's tech experience...

These are the REAL users, not us. They should be the main focus.

Twey
08-17-2007, 06:35 PM
I think you should definitely avoid opening a window for such a user -- he might not be able to work out how to close it :p Seriously, though, expecting a user to understand at least how to work their browser and window manager is not overly optimistic.

jscheuer1
08-17-2007, 09:15 PM
I think you should definitely avoid opening a window for such a user -- he might not be able to work out how to close it :p Seriously, though, expecting a user to understand at least how to work their browser and window manager is not overly optimistic.

We are definitely in 'eye of the beholder' territory now. I truly sympathise with your desire that all people are actually paying attention to the sorts of things you or I might, but the plain truth is they aren't. Overly optimistic? I'm all for optimism. What is called for here is realism. The folks at w3c are, for the most part geniuses, or at least, very into their subject matter. In reality, folks just turn the thing on and muddle through, expecting it to 'work'. They cannot be bothered with a machine that's more complicated than a car, TV, or a toaster, unless it can be assumed to behave as if it were, at least for them.

I'm in the relatively unique position of being able to see both sides, as I appreciate most, if not all that standards have to offer because of the mind I was equipped with at birth, while at the same time being somewhat the sort of person who just 'does things'. Most people (yourself and many others excluded) don't have the former, or if they do, focus it elsewhere, everyone has the latter in some degree.

What is the 'standard' for getting out of bed?

Twey
08-17-2007, 09:28 PM
In reality, folks just turn the thing on and muddle through, expecting it to 'work'.Well, it does work. A user who can't be bothered to figure out how to make his/her browser open links in a new window will be in a slightly less irritating position than one who can't work out how to stop links opening in a new window. The former is, in my experience, much easier to achieve.
I'm in the relatively unique position of being able to see both sides, as I appreciate most, if not all that standards have to offer because of the mind I was equipped with at birth, while at the same time being somewhat the sort of person who just 'does things'. Most people (yourself and many others excluded) don't have the former, or if they do, focus it elsewhere, everyone has the latter in some degree.However, I suspect that when you "do things" you also explore them enough to at least gain a basic understanding of them -- e.g. you've worked out that there's a right button on your mouse even though the right button is not a strict prerequisite to using a mouse.

I know what you mean about the two different mindsets, but there's a certain level of expertise I'd expect from anyone using a piece of equipment: someone using a toaster should also be aware of how to make it defrost bread, for example.
What is the 'standard' for getting out of bed?I think this is a non-sequitur: there's no standard for getting out of bed because it involves only one person. Standards are for communications. When two people meet, it's customary to, for example, smile, wave, bow, or kiss, depending on culture. When meeting someone for the first time someone from a Western culture might shake hands. Deviations from these standards can be tolerated in some situations, because we're humans: we're generally capable of understanding situations that differ from the accepted norm.

jscheuer1
08-17-2007, 10:14 PM
because we're humans: we're generally capable of understanding situations that differ from the accepted norm.

This is my basic point. Humans, generally do this, and expect their devices to as well. BTW, I think you could teach me a great deal about operating a toaster. Which reminds me, it is about time for me to start cooking dinner.