Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: target="_whatever" - To use or not to use

  1. #1
    Join Date
    Aug 2007
    Location
    Brazil
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default target="_whatever" - To use or not to use

    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!

  2. #2
    Join Date
    May 2007
    Location
    Viet Nam
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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 ^^

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    <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:

    Code:
    <!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:

    Code:
    <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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Aug 2007
    Location
    Brazil
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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!

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Aug 2007
    Location
    Brazil
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    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.

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •