<a href="#1"></a>
<a href="#2"></a>
<a href="#3"></a>
<script type="text/javascript">
window.onload = function(){
var a = document.getElementsByTagName('a'), i = 0, array = [];
while(i<a.length){
array.push(a[i++].hash);
}
alert(array.join(', '));
};
</script>