1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

HTML Strict - there is no attribute "TARGET".

Discussion in 'HTML & Website Design' started by djixas, Jun 28, 2007.

  1. #1
    I have one error left which drives me crazy.

    This page is not Valid HTML 4.01 Strict!

    Error Line 12 column 81: there is no attribute "TARGET".

    ...n.com" title="Site Main Page" target="_blank" class="topnav">Home Page</a><a h
    Code (markup):
    You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

    This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

    How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash.

    -----------------------------------

    How the .... I can fix it? Without using javascript.
     
    djixas, Jun 28, 2007 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #2
    Damned straight it's not supported - it was removed because forcing links to open in a new window is impolite to the user. In fact it's a behavior that royally torques me off.

    If I want to open the link in a new window, I'll do it manually (actually, I'd probably just middle click) - Forcing the user to have no choice BUT to open in a new window? Bad form.

    How to fix? REMOVE THE TARGET DECLARATION. It's obnoxious, it's annoying, GET RID OF IT.

    Sorry... pet peeve. Much akin to the classic "Download NOW" link that you have to jump through four pages just to get to the actual malfing download... which ends up relying on a broken javascript timer with no manual link should that /FAIL/
     
    deathshadow, Jun 28, 2007 IP
  3. smg

    smg Well-Known Member

    Messages:
    599
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    130
    #3
    You could always try using a javascript link
     
    smg, Jun 28, 2007 IP
  4. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Dan Schulz, Jun 28, 2007 IP
  5. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #5
    As deathshadow says, it's impolite to decide for the visitor that you're going to force a new instance of his browser. I'm not so adamantly opposed when the new window is actually helpful, such as opening a small help file to aid the visitor in whatever he's trying to accomplish on the page he's in, or maybe an enlarged version of some thumbnail image, that aids your visitor.

    It is a behavior, which belongs in scripting. The scripting must be unobtrusive, adding the behavior on top of the default—an enhancement.

    For the links you think will help the visitor if they open a new window, do this:
    
    <a href="some.html" [color=red]rel="external"[/color]>Somewhere</a>
    Code (markup):
    Now a bit of javascript in an external file or in the head.
    
    window.onload = function() {
      setLinks();
    }
    
    function setLinks() {
      if (!document.getElementsByTagName) return false;
      var links = document.getElementsByTagName("a");
      if (links.length == 0) return false;
      for (var i = 0; i < links.length; i++) {
        var relation = links[i].getAttribute("rel");
        if (relation == "external") {
          links[i].onclick = function() {
            return !window.open(this.href);
          }
        }     
      }
    }
    Code (markup):
    It's still possibly impolite, but it is unobtrusive and it fails gracefully.

    cheers,

    gary
     
    kk5st, Jun 28, 2007 IP
  6. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #6
    And, what happens if the visitor does not have javascript activated, or the UA doesn't do javascript? The link is permanently broken. Using a javascript link is a singularly Bad Idea.

    cheers,

    gary
     
    kk5st, Jun 28, 2007 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #7
    Which is why Lightboxes are a total /FAIL/, as that sure as shine ain't no enhancement. First thing I do on sites with them is turn javascript off... somehow clicking on a thumbnail on my broadband connected computer and having a 20k image take longer to appear than it would on DIALUP isn't real high up on my want list.

    Too much 'aint it neat' scripting out there which ends up costing functionality instead of adding it.
     
    deathshadow, Jun 29, 2007 IP
  8. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #8
    So what are you going on about? There are occasions where opening a new window can be desirable from the user's standpoint. As I pointed out, the javascript is added on top of the basic functionality. If you turn your js off, the link still works in the traditional manner. This ain't no 'ain't it neat' bit of scripting. Are you not paying attention?

    gary
     
    kk5st, Jun 29, 2007 IP
  9. x-noise

    x-noise Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    you could use javascript in combination with classes. select all the links in the page that have the class lets say "external", and add them a target:blank. in this manner your code will be clean, and you stii control the elements. The advantage is that the link is not broken if user does not have js enabled or the UA does not support JS.

    Btw: in css3 there will be a property that can control the way a link opens.
     
    x-noise, Jun 29, 2007 IP
  10. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #10
    Yes, a class could be used and would be friendlier toward IE which doesn't allow attribute based selectors, a la a[rel="external"] {} as a styling hook. The rel attribute would be more semantic, but no harm in helping the lame and the halt (IE).

    Adding the target attribute via javascript is still adding an invalid attribute—though the validator won't catch it. Attaching an anonymous window.open() onclick event handler is more appropriate.

    Notice that any failure by the javascript causes the normal link to fire.

    N.B. It appears that html5 may bring back the target attribute.

    cheers,

    gary
     
    kk5st, Jun 29, 2007 IP
  11. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #11
    in which case let the user CHOOSE instead of cramming it down their throat... or making them change their browser behavior because they don't like it.

    Good rule of thumb - anything that changes the expected behavior of a link... is PROBABLY not a good idea and is more likely to piss off the user than add any sort of 'functionality'.

    Take scripted download que's... Seriously, have you EVER been on a site that had those you didn't curse to the nine hells? I get that way every time a link opens in a behavior different from normal... 'for **** sake just show me the image', 'for **** sake why did this open a new window' and of course 'for **** sake just let me download the damned file!'

    But then I do tend to middle click on things more than left click these days.
     
    deathshadow, Jun 29, 2007 IP
  12. djixas

    djixas Well-Known Member

    Messages:
    749
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    110
    #12
    Well... Basically I was planning to add _blank only for links, which I sold... I think it would even be better for users.

    As far as I can see, there are three options:

    1. Remove _blank
    2. Use JavaScript
    3. Use Transitional instead of Strict

    I will pick 4th one: ignore this crazy error ;-)
     
    djixas, Jun 29, 2007 IP
  13. Els1

    Els1 Guest

    Messages:
    811
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #13
    gl fixing the problem i know how it feels getting errors and more errors
     
    Els1, Jun 29, 2007 IP
  14. djixas

    djixas Well-Known Member

    Messages:
    749
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    110
    #14
    I get this error only now. But seems Safari and Konquer renders site wrong... Will have to do some stuff then... :)
     
    djixas, Jun 29, 2007 IP
  15. youngdek

    youngdek Peon

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    thank for every body.
     
    youngdek, Apr 17, 2008 IP
  16. trichnosis

    trichnosis Prominent Member

    Messages:
    13,785
    Likes Received:
    333
    Best Answers:
    0
    Trophy Points:
    300
    #16
    i get the same problem and i have removed target tag from my links :)
     
    trichnosis, Jun 10, 2008 IP
  17. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #17
    To my great shame, I have not one but two pages on a site that have dropped down to Transitional for target. I hate target, but there was no other way around it. The rest of the site is HTML4.01 Strict, but that doesn't make me feel any better.
    In 99% of all cases (this is including Flash banners with a clickie button layer on top), target should be removed. No, the client does not "stay on your page." They leave it, with just an open window that they'll close when they're done surfing and discover that they have to close their browser 5 times.
     
    Stomme poes, Jun 10, 2008 IP
  18. subduedjoy

    subduedjoy Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    When a link goes to another domain, it should open in a new page so that users will be able to find the original site if they click out of the linked-to site. It's a pet peeve of mine when an off-site link does not open in a new page. I often click out of the linked-to site, and can not find the original one. Sometimes, depending on how I got to the original site to begin with, it is not in my history. So I can't find it so easily. The Ugh with having to click out of two sites is far less than the Ugh of having to find the original site. Plus, I always let the user know ahead of time that the link will open in a new page by providing a window icon next to the link. The user can then decide whether or not he/she wants to click on the link.
     
    subduedjoy, Apr 27, 2010 IP
  19. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #19
    Two year bump... JOY!

    Funny, I have the exact opposite pet peeve - but then I know how to middle click, ctrl-click, and know how to hit 'back' in my browser, and use a browser that has no 'history problems' you seem to be claiming..

    Then you are using one ****ed up browser buddy. Either that or you are on some garbage site where some nimrod decided AJAX emulating frames was a better choice than real links and separate pages - which it isn't.

    Not a problem here, if I care about the original site, I go back to it's tab... or hit 'back'.

    Yeah, and what if we want to click on it WITHOUT going to a tab/window? Using "target" or javascript asshattery doesn't even give the user the CHOICE.

    Target is a complete bullshit attribute meant for framesets and nothing else - abusing it for functionality already built into browsers; that's just stupid.
     
    deathshadow, Apr 30, 2010 IP
  20. Darden12

    Darden12 Well-Known Member

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #20
    I understand why you say forcing new window is impolite, but then how do you handle the following case without forcing a new window:

    You have a Net radio station (in this case Live365) widget on your page: If someone clicks on another link on your page WHILE they're listening to your station through the widget, then the station will stop playing.



     
    Darden12, May 10, 2011 IP