The target=”_blank” xhtml strict workaround

A simple Question with a simple answer :
How do I open links in a new tab or window without using target="_blank", so that my page can still validate as XHTML?

There are a load of options on google, most of them pretty confusing. But consider the following HTML :

<a href="" id="link_id">link</a>

The best method is to use Javascript:;

Implement it in the following unobtrusive and progressively enhanced way, in an external javascript file:

document.getElementById("link_id").onclick = function () {; return false;

or when using jquery :

$("#link_id").click( function() {;
    return false;

Leave a Reply