var links;
function onInit () {
/* First, we get the div */
var theDiv = document.getElementById("ex");
/* Now, we fill the links list (declared above) */
links = theDiv.getElementsByTagName("a");
/* Now, we loop through the links list */
for (i=0; i < links.length; i++) {
/* For each link:
Make it call popup function (with link number) when it is clicked
Store the old href somewhere. Since Javascript allows you to add
a variable wherever, just make a property "oldHref"
Set the href of the link to something that does nothing, so we are
not bothered by what the link was originally supposed to do
before we changed it.
*/
links[i].onclick = "myShowPopup(" + i + ");";
links[i].oldHref = links[i].href;
links[i].href = "javascript:void(0);";
}
}
function myShowPopup(i){
var path = links[i].oldHref;
/* Do whatever code you want to open a popup window to "path" */
}