Two questions on the function below that executes at document load time.
1: document.links at LINE1 below contains just the file name and not the href absolute URL? Since the function fails on document.link[0] I can only say it contains: index.php, when it should contain [
localhost...] right?
2: mystring.lastIndexOf (LINE2) fails with 'lastIndexOf not a function' when it certainly is and I am using it several times in another page with almost the exact syntax.
function links_onclick(){
for(var i=0; i<document.links.length; i++){
var mystring = document.links[i];//LINE1
var myfilename = mystring.substr(mystring.lastIndexOf("/") + 1);//LINE2
if(myfilename == "phantom.html"){
window.document.links[x].onclick = function(){
var msg = "";
msg += "Invoked by onclick property of the a element.\n\n";
msg += "Invoked function will cancel the href action by\n";
msg += "returning 'false'.\n";
alert(msg);
return false;
}
}
}
}
I'm learning about creating behaviors as properties and this looks right and I've used document.links and lastIndexOf tens of times but I may have my load and rendering concept twisted? Any help much appreciated. Thanks all.