Forum Moderators: open
The original thing I built relied heavily on frames. Frames suck, so I'm trying to avoid them now, by using an iframe and adding some more to the page I use (a utility for work).
I have a script that takes a link and puts part of the URL and the text of the link in a textbox. This works. The problem now, is that it affects all links on the page, and apparently interferes with another script.
Here's the script:
function addClick(){
for (i=0;i<document.links.length;i++){
document.links[i].onclick = intercept;
}
}
function intercept(){
document.getElementById('boxy').value = this.href.replace(/^.*?:\/\/.*?(\/.*)$/, "$1") + '\r' + this.innerHTML.replace(/<\/?.*?>/g, "");
}
Now, is there a way to have this script only affect links within a certain div? I tried changing document.links. to document.getElementById('thedivID').links, but with no luck.
Any suggestions on where I should go from here?
var div = document.getElementById('thedivID');
if(!div ) return;
var aNodeList = div.getElementsByTagName("A");
for( var i = 0; i < aNodeList.length; i++ )
{
aNodeList.item(i).onclick = intercept;
}
I haven't tried that, but I think it'll work.