jscheuer1 gave me this code a while back since then
I tried to replace:
Code:
if (targ == Mlinks[i]){
alert (Mlinks[i].href? 'The href is:\n' + Mlinks[i].href :
Mlinks[i].firstChild && Mlinks[i].firstChild.nodeValue? 'The first child node value is:\n' + Mlinks[i].firstChild.nodeValue :
"The 'a' tag in the 'navebase' division that was clicked has no href and no immediate text node.");
return;
with:
Code:
if (targ==Mlinks[i].childNode[0]) {do something}
if else (targ==Mlinks[i].childNode[0]) {something else}
this just wont work it make no since so I wanted to use the links array of Mlinks but there is no way to connect targ to that and no I can find no info on the links array because there is no such thing
should I load the links with javascript from an array first. Then run jscheuer1's code modified to find out what number was the link that was clicked in the div navebase.
is this the only way to find out what link was clicked in a div and what number was the link if each link came one after another.
I'm sorry if I never asked about thing in the first thread; I though I knew how to change it.
Code:
<head>
if(document.getElementById)
document.onclick = function (e){
e = e? e : window.event;
var targ = e.target? e.target : e.srcElement,
Mlinks = document.getElementById('navebase').getElementsByTagName('a');
while(targ.parentNode && targ.parentNode.tagName && targ.tagName.toLowerCase() != 'a')
targ = targ.parentNode;
for (var i = Mlinks.length - 1; i > -1; --i)
if (targ == Mlinks[i]){
alert (Mlinks[i].href? 'The href is:\n' + Mlinks[i].href :
Mlinks[i].firstChild && Mlinks[i].firstChild.nodeValue? 'The first child node value is:\n' + Mlinks[i].firstChild.nodeValue :
"The 'a' tag in the 'navebase' division that was clicked has no href and no immediate text node.");
return;
}
alert("Something other than an 'a' tag in the 'navebase' division was clicked");
};
else alert ("A 'version 5' or better Browser is required for this script.");*/
</head>
<body>
<div>
Some Stuff Here<br>
<a href="http://www.dynamicdrive.com/">DD</a>
</div>
<div id="navebase">
<a href="#" onClick="return false;">Hi</a><br>
<a>Bobalou</a><br>
<a><span class="redder">Dead?</span></a> <br>
<a href="#" >Click me</a> <br>
<a><span class="redder">getting there</span></a> <br>
</div>
<body/>
Bookmarks