Simplest XHTML 1.0 strict alternative to target=”_blank”
Sep 27th, 2011 by admin
The most common method of having a link open in a new window i.e., target=”_blank” is invalid markup as per XHTML 1.0 strict.
If, like me, you are a stickler for valid strict markup, here’s the easiest solution to maintain markup validity when you must have your links open in a new window/tab.
Old markup -
<a
href="http://www.cybermilitia.net"
title="Cyber Militia"
target="_blank">
The most awesome site !
</a>
new XHTML 1.0 strict valid markup -
<a
href="http://www.cybermilitia.net"
title="Cyber Militia"
onclick="window.open(this.href, '_blank');return false;">
The most awesome site !
</a>
All done with a wee-bit of javascript.