[thelist] How do you validate an A link with a "target"?

Hassan Schroeder hassan at webtuitive.com
Wed Apr 17 16:37:10 CDT 2002


"Luther, Ron" wrote:

> Is there some syntax that will give me "open this link in a new
> window" functionality that will validate to 4.01 strict?
>
> I was trying the <a target="foo" href="bar?one=1&two=2">Here</a>
> and the w3c validator says it doesn't like "target".

If you want to validate to a DTD that doesn't include the TARGET
attribute, you can set the target /property/ via JavaScript.

For one link,

 <a href="/tmp/margin.html" onclick="this.target='foo';">margin</a>

For all links,

 <head>
 <script type="text/javascript">
  function adjustLinks()
   {
     for ( var i = 0; i < document.links.length; i++ )
      {
        document.links[i].target = "foo";
      }
   }
  </script>
 </head>
 <body onload="adjustLinks();">

    <a href="/some/other/page.html">somewhere</a>

 </body>

HTH!
--
H*
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

    -- creating dynamic Web sites and applications since 1994 --



More information about the thelist mailing list