SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: Target="_blank"

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Target="_blank"

    Sorry if I am asking a dumb question, but I am trying to validate one of my web pgaes and the W3 Markup Validation Service is saying the target="_blank" is not supported under Strict XTHML.

    Does anybody know how I can overcome this issue or is it the case that when a user clicks on a link within your page they are are taken away from your page and on to the new page?

    Cheers

  2. #2
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    This has come up several times and the definitive answer is to either switch to a Transitional doctype or remove the target attribute from the file.

    Or there is this: http://www.sitepoint.com/article/sta...ompliant-world

    Hope it helps.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Johnny,

    I was thinking this might be the case. In the back of my mind I had it that strict XHTML meant no pop-up's even though this is really not a pop-up but a new window upon a client request.

    Will review the link you left, thank you for the swift response!

  4. #4
    SitePoint Enthusiast
    Join Date
    May 2006
    Location
    London
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was always under the impression that the reason this failed in 'strict' validation, was because when the user clicks on a link it should load the linked page in the same window, and not open a new one, it's all about user experience and giving the user the option to use the 'back' button as users often do, rather than just dictating to them and firing off 'possibly' yet another window, do pop up blockers get in the way of this too?!?

    Anyway, I had this issue with a site I did last year, the client wanted the links to open in a new window but I wasn't happy with that, as it failed strict validation, so in the end we compromised and I added a piece of text labelled 'webtip' in an appropriate place. This informed the user that if they wanted to open the link in a new window they would have to hold down the 'shift' key then click the link.

    A reasonable and easy to implement compromise I thought.

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PompeyTim View Post
    I was always under the impression that the reason this failed in 'strict' validation, was because when the user clicks on a link it should load the linked page in the same window, and not open a new one
    There are two reasons why the target attribute is not allowed in HTML 4.01 Strict, XHTML 1.0 Strict or XHTML 1.1:
    1. It is really meant to be used within a frameset, and the use of frames is not recommended anymore. Using target to open new browser windows is not the intended primary use.
    2. A Strict DTD emphasises the separation of content (HTML or XHTML), presentation (CSS) and behaviour (JavaScript). Opening new windows is behaviour, thus it should be done with JavaScript.
    Birnam wood is come to Dunsinane

  6. #6
    SitePoint Enthusiast
    Join Date
    May 2006
    Location
    London
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh I see, thanks for clearing that one up!

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    I recall reading or being told here that target="_blank" was deprecated......
    or I might just be going mad through lack of sleep
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #8
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ View Post
    I recall reading or being told here that target="_blank" was deprecated......
    or I might just be going mad through lack of sleep
    The target attribute alone is deprecated, not just target="_blank" No you are not mad, it is deprecated for the 2 reasons Tommy mentioned above.

  9. #9
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    woooo, see I told you I wasnt crazy - damn voices in my head - I told you Ha!
    OK you can stop talking to me now... I said stop - no I wont eat that pickled herring, put the damn gun down......
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  10. #10
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    The 'target' attribute is not deprecated as such in XHTML 1.0 since it never appeared in HTML Strict in the first place.

  11. #11
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)


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
  •