function getValues(element) { value = { src: element.getAttribute('href'), // Get src title: element.getAttribute('title') // Get title }; return value; } function display(value) { } window.onload = function() { if(document.getElementById && document.createTextNode) { // We are working with a modern browser if(document.getElementById('thumbnails')) { var links = document.getElementById('thumbnails').getElementsByTagName('a'); // Get links for(var i = 0; i < links.length; i++) { links[i].onclick = function() { var value = getValues(this); // Get values display(value); // Display image //alert(value.src + '\n' + value.title); return false; // Stop browser from following link } } } } }