HTML:
<a href="/">1</a> // link to http://site.com
<a href="/section/page/">2/a> // link to http://site.com/section/page/
<a href="http://site.com/">3</a>
<a href="../gallery/1/">4</a> // link to http://site.com/gallery/1/
JS:
$("a").live('click', function(){
var url = $(this).attr("href");
//do something
});
How to convert relative path (var url
) to absolute by jQuery?
Script should do nothing, if it is already an absolute path.
Thanks.