J
johkar
In Firefox when I simulate a click on a link, the link reference ('a')
is returned to function showFK(a) as 'undefined'. Since the link
reference is undefined style changes cannot be executed. Ideas?
Here is the link:
<a href="someURL.htm" onclick="return showFK(this)">Auto</a>
//The link calls this function:
function showFK(a) {
a.style.display="none";
a.parentNode.children["fk"].style.display="inline";
return false;
}
//This code is executed on page load; it loops through all the links
with text of 'Auto' and clicks them:
var lnk, lnkLgth, sel, selLgth, eventObj;
lnk=document.getElementsByTagName('a');
lnkLgth=lnk.length;
for(i=0;i<lnkLgth;i++){
if(lnk.firstChild.nodeValue=='Auto'){
if(document.createEvent){
eventObj=document.createEvent('MouseEvent');
eventObj.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0,
false, false, false, false, 0, null);
lnk.dispatchEvent(eventObj);
}
else {
lnk.click();
}
}
}
sel=document.getElementsByTagName('select');
selLgth=sel.length;
for(i=0;i<selLgth;i++){
sel.selectedIndex=sel.options.length-1;
}
is returned to function showFK(a) as 'undefined'. Since the link
reference is undefined style changes cannot be executed. Ideas?
Here is the link:
<a href="someURL.htm" onclick="return showFK(this)">Auto</a>
//The link calls this function:
function showFK(a) {
a.style.display="none";
a.parentNode.children["fk"].style.display="inline";
return false;
}
//This code is executed on page load; it loops through all the links
with text of 'Auto' and clicks them:
var lnk, lnkLgth, sel, selLgth, eventObj;
lnk=document.getElementsByTagName('a');
lnkLgth=lnk.length;
for(i=0;i<lnkLgth;i++){
if(lnk.firstChild.nodeValue=='Auto'){
if(document.createEvent){
eventObj=document.createEvent('MouseEvent');
eventObj.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0,
false, false, false, false, 0, null);
lnk.dispatchEvent(eventObj);
}
else {
lnk.click();
}
}
}
sel=document.getElementsByTagName('select');
selLgth=sel.length;
for(i=0;i<selLgth;i++){
sel.selectedIndex=sel.options.length-1;
}