dcsimg
www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: XHTML 1.1 --> target attribute

  1. #1
    Join Date
    Oct 2003
    Location
    Vancouver, WA
    Posts
    25

    XHTML 1.1 --> target attribute

    I am in the process of developing a new site. The plan is to have the site comply with the XHTML 1.1 Recommendation. Upon validating the documents that I have, I receive the following error:

    Error: there is no attribute target for this element (in this HTML version)
    I need to use the target attribute, or something similar, to cause the browser to open the link in a new browser window. Is there an attribute for the a element in XHTML 1.1 that will do this?

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Nope. You can, however, use JavaScript to open it in a new window:

    <a href="http://www.w3.org/" onclick="window.open(this.href); return false;">W3C</a>

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  3. #3
    Join Date
    Jul 2003
    Location
    Boston Area, Massachusetts
    Posts
    3,487
    Also:
    Code:
    <a href="http://www.google.com/" onclick="target='_blank';">Google</a>

  4. #4
    Join Date
    Aug 2003
    Location
    In front of my computer
    Posts
    726
    can u open a window using php? if so, could one do action="open.php" then have open.php open the new window and ergo, it be valid plus work for all users instead of working for 87% like JS?
    Theres this thing called imperfection. Its the one thing everyones got but nobody wants.

    I.. HATE.. EVERYTHING ABOUT YOU! Why do.. I Love you? I HATE Everything about you! Why do I.. love you??? Everytime we lie awake... after every hit we take.. every feeling that i get.. but i haven't missed you yet. only when I stop to think about it... I.. HATE.. EVERYTHING ABOUT YOU! Why do.. I Love you? I HATE Everything about you! Why do I.. love you?

  5. #5
    Join Date
    Nov 2002
    Location
    Dartmoor [Holiday]
    Posts
    2,382
    No, PHP runs on the server-side and hence cannot open new windows, which is an inherently client-side activity. AFAIK, the best method is pyro's, which will open a new window if JS is enabled and use the current one if it is not.

    Adam
    "If youíre not using valid HTML, then you havenít created a Web page. You may have created something else, but it isnít a Web page." - Joe Clark

    Do something amazing (USA) | Make Poverty History

  6. #6
    Join Date
    Nov 2002
    Location
    XYZZY - UK
    Posts
    1,760
    Alternatively you use the eXtensibility aspect of XHTML 1.1 and reintroduce the target but it was removed for a good reason.

  7. #7
    Join Date
    Aug 2003
    Location
    In my house
    Posts
    4,004
    Originally posted by Robert Wellock
    it was removed for a good reason.
    Just curious, but what would that reason be?
    Thousand different paths
    So many sterile ends
    I chose the Devil's path

    Never shall the sun kiss my face
    And caress me with it's burning light
    For I dwell in the shadows
    And sleep side by side with death

  8. #8
    Join Date
    Jul 2003
    Location
    Boston Area, Massachusetts
    Posts
    3,487
    Originally posted by Paul Jr
    Just curious, but what would that reason be?
    Two things come to mind:
    1. It causes accessibility problems.
    2. Users should be able to decide whether they want links to open in a new window or not.

  9. #9
    Join Date
    Aug 2003
    Location
    In my house
    Posts
    4,004
    Originally posted by fredmv
    Two things come to mind:
    1. It causes accessibility problems.
    2. Users should be able to decide whether they want links to open in a new window or not.
    Thanks for the linkage, and I completely agree. I don't like it when people have new windows opening all over the place.
    Thousand different paths
    So many sterile ends
    I chose the Devil's path

    Never shall the sun kiss my face
    And caress me with it's burning light
    For I dwell in the shadows
    And sleep side by side with death

  10. #10
    Join Date
    Feb 2004
    Posts
    9
    There are some times when a new window is desirable and I recently ran across some tags from PayPal for insertion of their logo that included the target attribute. So if I wanted to include the logo I would have to alter their tags but I couldn't find an alternative in xhtml. However I believe that is only true if you validate as strict. According to what I read it will work in xhtml as transitiional. In my case the logo wasn't that important and I scrapped it.
    I am surprised that this is not an option to developers using xhtml and validating strict however. There are definately times when a new window is desirable.
    Tom Beach
    http://www.northcrafts.com

  11. #11
    Join Date
    Jul 2003
    Location
    Boston Area, Massachusetts
    Posts
    3,487
    Originally posted by tbeach44
    I am surprised that this is not an option to developers using xhtml and validating strict however.
    Technically, it is. Did you read this entire thread? You can either emulate it using JavaScript and thus still being degradable, or use the extensibility aspect of XHTML and add the attribute yourself as Robert has already implied.
    Last edited by fredmv; 04-02-2004 at 11:34 AM.

  12. #12
    Join Date
    Feb 2004
    Posts
    9
    Originally posted by fredmv
    , or use the extensibility aspect of XHTML and add the attribute yourself as Robert has already implied.
    Could you explain that please.
    Tom Beach
    http://www.northcrafts.com

  13. #13
    Join Date
    Nov 2002
    Location
    XYZZY - UK
    Posts
    1,760
    I can explain it visit http://www.xhtmlcoder.com/beck.htm click on one of the movie links watch the movie view the page source.

    Notice I have used <embed /> find the that page address; shove the page containing the embedded QuickTime Movie through the W3C Validator and notice it validates even though <embed /> is not an official W3C element.

    In other words I have added a new element called <embed /> to XHTML 1.0 Strict; eXtending by using the Black Arts of EBNF and DTD hence applying eXtensibility.

  14. #14
    Join Date
    May 2003
    Location
    Andover, UK
    Posts
    410

    validation error, target with anchor tag

    I am in the process of converting one of my sites to xhtml1.0 strict. For the <a> tag, w3schools states that there is no difference between html and xhtml, yet several pages which use the line:
    <a href="index.html" target="_top">Home Page</a> no longer validate with the error "You have used an attribute with an element that is defined not to have that attribute" yet the example given is
    <a href="http://www.w3schools.com" target="_blank">W3Schools</a>
    Does this mean that for xhtml1.0 that w3schools is incorrect ?

  15. #15
    Join Date
    May 2003
    Location
    Vancouver, WA
    Posts
    47
    Jason,

    I went though the same problem when creating my site

    I decided to ditch it in the long run though. IM me sometime... im interested in seeing what your working on.


    Bryan

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles