SitePoint Sponsor

User Tag List

Results 1 to 19 of 19

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2006
    Location
    Australia
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Serving "Valid" XHTML Strict with target="_blank"

    I just ran w3 validator on my site and it came back with this error

    Error Line 103 column 49: there is no attribute "target". <a href="http://www.anikafoundation.com" target="_blank">the anika foundation</a>

    So I did some reading and found out that xhtml 1.0 strict doesn't support target attributes. I found a way around this here but am curious to know whether this is the best way to achieve the original purpose of the "_blank" attribute.

    cheers

  2. #2
    SitePoint Wizard bronze trophy Tyssen's Avatar
    Join Date
    Oct 2005
    Location
    Brisbane, QLD
    Posts
    4,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's an article on Sitepoint that discusses a method that involves using the 'rel' attribute but I can't seem to find it now.

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    target blank

    The page you posted a link to seems to be about the same as this Sitepoint article
    http://www.sitepoint.com/article/sta...ompliant-world

  4. #4
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tylerdurden
    [...] but am curious to know whether this is the best way to achieve the original purpose of the "_blank" attribute.
    What is the purpose? (Yeah, to open a new window, but why?)
    Simon Pieters

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2006
    Location
    Australia
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zcorpan
    What is the purpose? (Yeah, to open a new window, but why?)
    what are you on about?

  6. #6
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tylerdurden
    what are you on about?
    It's hard to come with a good solution if you don't know the problem or the use-case.
    Simon Pieters

  7. #7
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    new windows

    Quote Originally Posted by tylerdurden
    what are you on about?
    I think the point is that users should have control of their browsers and decide if they want to open a new window. Openning a new window could be considered a form of browser hi-jacking. Personally I don't mind as long as it isn't obnoxious. I certainly don't want spawns openning unless I know they're going to open. There is a reason pop-up blockers are so popular. But it seems to me if the link has a "opens in new wndow" next to it and I choose to cllck the link it isn't so bad. (Similarly, I think it's courteous to say "15MB swf file" next to a link to a huge media file download) Just the same, I prefer to open links to external sites in new tabs, not windows.
    In any case you should consider just how important it is to open a new window, as it will certainly annoy some users.

  8. #8
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    If you want to use the target attribute, use XHTML transitional. It's not going to kill your web designer cred, don't worry

  9. #9
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    This is the only thing keeping some of my XHTML Transitional pages from validating as Strict.

    I just skimmed the SP article and see that it's using some JavaScript to open new windows by... putting the target attribute back on the links.

    Out of curiosity, how would you have links that modify frames, or a popup window's parent, or an iframe window's parent without the target attribute? More JavaScript hacks?

  10. #10
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Dan Grossman
    Out of curiosity, how would you have links that modify frames, or a popup window's parent, or an iframe window's parent without the target attribute? More JavaScript hacks?
    You're not supposed to use frames/iframes in Strict mode. Actually I think iframes are deprecated in Strict mode.

    As for the popup window's parent, use Javascript.
    Code:
    window.opener.location.href = 'whatever.html';

  11. #11
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Fair enough

  12. #12
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    valid mark-up

    I have seen an example where the page was using the embed tag. To get the page to validate, the author used a custom DTD. So there are ways to get "invalid" pages to "validate". The question is, are you writing pages to pass validation, or for the user?

  13. #13
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Mittineague
    The question is, are you writing pages to pass validation, or for the user?

  14. #14
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague
    To get the page to validate, the author used a custom DTD. So there are ways to get "invalid" pages to "validate".
    It still isn't conforming. Passing DTD validation means next to nothing. The HTML4 spec forbids authors to "extend" HTML though SGML features.
    Simon Pieters

  15. #15
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    valid vs conforming

    Quote Originally Posted by zcorpan
    Passing DTD validation means next to nothing.
    Exactly my point. Just writing pages that will validate for the sake of having them validate while ignoring problems users may experience is focusing on the wrong goal. Although I might not use the word "forbid", the reference you linked to is correct.
    For reasons of interoperability, authors must not "extend" HTML through the available SGML mechanisms (e.g., extending the DTD, adding a new set of entity definitions, etc.).
    Sure the page might be "bleeding edge" and "validate", but are users going to have problems with it?
    I think that the validator should be used as a tool to help write conforming pages, not as some kind of "proof" that the pages are OK because you want them to be.
    I can't speak for others, but my conscience would bother me if I purposely took advantage of one of the validators "limits" and tried to convince myself that I hadn't.

  16. #16
    SitePoint Member
    Join Date
    May 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's a JavaScript workaround documented here: <snip>
    Last edited by Dan Grossman; May 16, 2009 at 20:21. Reason: self-promotion

  17. #17
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The solution to the target attribute probloem is to not use it and let your visitors decide where to open what. At least some of them will override the target anyway.

    The solution to the iframe/embed problem is to use object tags. The only issue with correctly coded object tags is that IE always puts a border around it.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  18. #18
    Resident curmudgeon bronze trophy gary.turner's Avatar
    Join Date
    Jan 2009
    Location
    Dallas
    Posts
    990
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're importing an html page, i.e.text/html, IE<8 will also add a phantom vertical scrollbar, whether needed or not.

    For example, if you have Amazon ads, they're normally put in an iframe. If you use object, and size to accommodate the ad size, IE<8 gives you a scrollbar, which takes from the width, which means you get a horizontal scrollbar. And that means you have two pug-uglies that cause you to need to scroll. Yikes!

    As much as I dislike it, that forces me to use a transitional DTD. :shrug:

    cheers,

    gary
    Anyone can build a usable website. It takes a graphic
    designer to make it slow, confusing, and painful to use.

    Simple minded html & css demos and tutorials

  19. #19
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    This thread is more than 3 years old, if there's a desire to discuss this still, I suggest starting a new one


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
  •