pathFile chiaramente deve diventare globalecodice:<script type="text/javascript" language="Javascript"> function relTransform() { var ancore=document.getElementsByTagName("a"); pathFile=new Array; for (i = 0; i < ancore.length; i++) { if(ancore[i].getAttribute("rel")=="il_mio_rel") { pathFile[i]=ancore[i].getAttribute("href"); ancore[i].setAttribute("href","#"); // -> questo quello che devi aggiungere var ancora=ancore[i]; keepRef(ancora,i) } } } // -> questo quello che devi aggiungere function keepRef(obj,num){ obj.onclick=function(){la_mia_funzione(pathFile[num]);return false} } //questa è per testarla function la_mia_funzione(variabile) { window.alert(variabile); } </script>