srk
05-23-2005, 09:09 PM
Hi!
I have a piece of code to accomplish the following:
When I tab to first cell of the Table and press spacebar, the click event should be triggered and alert message should pop up.
It works fine in IE but not in FireFox. Please suggest what I am doing wrong?
In FireFox, Javascript console shows the following error:
thisEl.click() is not a function.
My Code:
----------------------------------------------------------------------
<HTML DIR=LTR>
<HEAD>
</HEAD>
<BODY>
<TABLE BORDER=1>
<TR>
<TD id = 'R1C1' onkeydown="checkKey(event)"; onClick="alert('Test1-a')";><a href=#>Test1-a</a></TD>
<TD><a href=#>Test2-a</a></TD>
<TD><a href=#>Test3-a</a></TD>
</TR>
<TR>
<TD><a href=#>Test1-b</a></TD>
<TD><a href=#>Test2-b</a></TD>
<TD><a href=#>Test3-b</a></TD>
</TR>
<TR>
<TD><a href=#>Test1-c</a></TD>
<TD><a href=#>Test2-c</a></TD>
<TD><a href=#>Test3-c</a></TD>
</TR>
</TABLE>
<SCRIPT>
var thisEvt = null;
var thisEl= null;
var ie4 = (navigator.appName.indexOf("Internet Explorer") !=-1) ? true: false;
function checkKey(evt){
if (!ie4) {
thisEvt = evt ;
thisEl=thisEvt.target ;
} else { thisEvt = window.event ; thisEl=thisEvt.srcElement ; }
if(thisEvt.keyCode==32){
thisEl.click();
}
}
</SCRIPT>
</BODY>
</HTML>
----------------------------------------------------------------------
Please help,
SRK
I have a piece of code to accomplish the following:
When I tab to first cell of the Table and press spacebar, the click event should be triggered and alert message should pop up.
It works fine in IE but not in FireFox. Please suggest what I am doing wrong?
In FireFox, Javascript console shows the following error:
thisEl.click() is not a function.
My Code:
----------------------------------------------------------------------
<HTML DIR=LTR>
<HEAD>
</HEAD>
<BODY>
<TABLE BORDER=1>
<TR>
<TD id = 'R1C1' onkeydown="checkKey(event)"; onClick="alert('Test1-a')";><a href=#>Test1-a</a></TD>
<TD><a href=#>Test2-a</a></TD>
<TD><a href=#>Test3-a</a></TD>
</TR>
<TR>
<TD><a href=#>Test1-b</a></TD>
<TD><a href=#>Test2-b</a></TD>
<TD><a href=#>Test3-b</a></TD>
</TR>
<TR>
<TD><a href=#>Test1-c</a></TD>
<TD><a href=#>Test2-c</a></TD>
<TD><a href=#>Test3-c</a></TD>
</TR>
</TABLE>
<SCRIPT>
var thisEvt = null;
var thisEl= null;
var ie4 = (navigator.appName.indexOf("Internet Explorer") !=-1) ? true: false;
function checkKey(evt){
if (!ie4) {
thisEvt = evt ;
thisEl=thisEvt.target ;
} else { thisEvt = window.event ; thisEl=thisEvt.srcElement ; }
if(thisEvt.keyCode==32){
thisEl.click();
}
}
</SCRIPT>
</BODY>
</HTML>
----------------------------------------------------------------------
Please help,
SRK