Using jQuery to over come the shortsomings of XHTML
Who would have ever have know that you couldn’t do a target=”blank” on an anchor tag with XHTML Strict? I didn’t and this caught me by surprise. I haven’t a clue why the w3c even thought to do this. I think that the target attribute is probably the most useful attribute in the HTML language.
Anywho, this really isn’t a problem since I use jQuery! By using the power of jQuery you can overcome this problem. What I did was follow the advice of this post and use the “rel” attribute with a value of “external”. Then using jQuery I’m able to search the DOM for an anchor tags that are marked and open a new window. The code is below:
<a href=”http://www.jquery.com” rel=”external”/>
// fix for target=”_blank”