<script type="text/javascript">
window.onload = function(){
var links = document.getElementById('links').getElementsByTagName('a'), i = links.length, array = [];
while(i--){
links[i].onclick = function(i){
return function(){
if(array.join().search("#") == -1){
this.href = '#';
array.push('#');
return false;
}
else {
return true;
}
};
}(i);
}
};
</script>
<div id="links">
<a href="http://ya.ru">link1</a>
<a href="http://ya.ru">link2</a>
<a href="http://ya.ru">link3</a>
<div>