jslink

by Vladimir

HTML

Old link: <a href='http://google.com'>Google.com</a><br />
New link: <u class='jslink' rel='http://google.com'>Google.com</u>

JavaScript

$(document).ready(function()
{
    var w=window,
    jslnk=[];
    $(".jslink").live("click",function(e)
    {
        if(e.ctrlKey)
            jslnkopennew($(this).attr("rel"));
        else
            w.location.href=$(this).attr("rel")
    });
    $(".jslink").live("mousedown",function(e)
    {
        if(e.which==2)
        {
            jslnkopennew($(this).attr("rel"));
            e.preventDefault();
            e.stopPropagation()
        }
    });
    function jslnkopennew(url)
    {
        jslnk.push(w.open(url,"_blank"));
        w.focus()
    }
});