Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    target="_blank" in XHTML 1.0 Strict

    Hey, on my most recent design I have some links that I would like opened in a new window, however if I add the target attribute it says that it doesnt exist. i have looked but cant find a way around opening links in a new window? Anyone know how? Thanks.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    Kansas City, Kansas
    Posts
    1,518
    Thanks
    0
    Thanked 2 Times in 2 Posts

  • #3
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    target-new: new
    Soon...
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok thanks for that, the only problem is most of my links dont actually have a class name, does this mean I would need to make a class for the links?

  • #5
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,699
    Thanks
    0
    Thanked 233 Times in 228 Posts
    Hi there missing-score,

    This code does not rely on 'class' but on tag name...

    Code:
    <script type="text/javascript">
    //<![CDATA[
     function setTarget(){
      var a = document.getElementsByTagName("a");
      for(var i = 0;i < a.length;i++){
       a[i].target = "_blank";
      }
     }
    //]]>
    onload=function() {setTarget();}
    </script>

    cthead

  • #6
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cheers thanks ill get it added soon

  • #7
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, it works! however I will make a separate class for new window links as some links I want to open in the same window so It will just make life easier.

    Thanks for your help

    EDIT: Got it working, and I will upload it tomorrow

  • #8
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    I maybe wrong but I always thought that new windows should be opened by the users choice, not yours. Which is why they stopped using that in xhtml.

  • #9
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I can see your point, and I know if people are going to leave my site then a new window wont stop them... but I would rather have off site links open in a new window, and also it allows me to break out of the frame I am stuck in for the off site links.

  • #10
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post
    I may be wrong, but you don't need a script for this. Just modify the DTD to suit your needs. The W3 Validator didn't have a problem with this:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [<!ATTLIST a target CDATA #IMPLIED>]>

  • #11
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts
    target-new:

    is that a forthcoming CSS property? i hope they reconsider. i find even the slight blurring of presentation and behavior with :hover a bit odd. a more knowledgeable gentleman than myself has written an article on the topic that's worth checking out. he doesn't draw any conclusions necessarily about whether even :hover should or should not be a part of CSS, so it's more of a 'get ya thinking' type piece. very interesting observations. for instance, the CSS methods for rollout menus are extremely efficient and compact on the code side, but what sense does it make using the presentation layer to control behavior? etc.

    http://digital-web.com/articles/sepa..._presentation/

  • #12
    Regular Coder
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    302
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by missing-score
    I would rather have off site links open in a new window
    Why don't you just add a title spec so that when you viewers mouseover the offsite link, it says something like title="this is an offsite link"? And to have the offsite link(s) break out of your frame, put target="_top" into the link.

  • #13
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Because, as he said, he is using XHTML strict which has deprecated the "target" attribute..

  • #14
    Regular Coder
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    302
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by ]|V|[agnus
    Because, as he said, he is using XHTML strict which has deprecated the "target" attribute..
    In which case, it seems that frames cannot be used if he is using XHTML strict.... ie: frames
    are supported in the w3c.org XHTML 1.0 strict doc type.

    (I have stared and stared at what appears to be English in



    and cannot understand how one would get links to open in various frames if target= is not allowed - not that it matters though - I've never been a big fan of frames anyway)

    And personally, I would still advocate the use of title="this is an offsite link" over opening in a new window.

  • #15
    Regular Coder
    Join Date
    May 2004
    Location
    Minneapolis, MN, USA
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's deprecated in the Strict DTD, but not the Transitional DTD. So, I believe the proper use of the XHTML frameset would be to then use XHTML Transitional or HTML pages within the frames.

    But I dunno. I avoid frames like the plague now.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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