I have this script, but need the extract URL part:

<script type="text/javascript">
var links = new Array();
links = document.getElementsByTagName('a');
for(var i=0;i<links.length;i++){
var tempfunc = links[i].onclick;
//*****EXTRACT THE URL*****//
var url = "http://www.sitepoint.com"; //say this is the url you extracted
links[i].onclick=function(){top.location.href=url};
}
</script>