All,
I was trying to add an onclick event using setAttribute to a <tdfrom
javascript. Apparently the code doesnot seem to work in FF3 but works
pretty well in IE7.
Here is the snippet for ur reference:
<...
var _table=document .createElement( "table");
_tbody=document .createElement( "tbody");
var _tr = document.create Element("tr");
var _td = document.create Element("td");
_td.innerHTML=" 6";
_td.id=""+x+"_" +y+"";
_td.setAttribut e("onclick",fun ction(){check(e vent);});
_tr.appendChild (_td);
_tbody.appendCh ild(_tr);
_table.appendCh ild(_tbody");
....
And here is function "Check's" definition
function check(e){
if (!e)
{
var e=window.event;
alert(e+" :None");
}
if (e.target)
{
targ=e.target;
alert("FF/Netscape: ");
}
else if (e.srcElement)
{
targ=e.srcEleme nt;
alert("IE");
document.getEle mentById(e.srcE lement.id).inne rHTML="0";
}
alert(targ.tagN ame);
}
Any help in tracking this problem would be really useful.
I was trying to add an onclick event using setAttribute to a <tdfrom
javascript. Apparently the code doesnot seem to work in FF3 but works
pretty well in IE7.
Here is the snippet for ur reference:
<...
var _table=document .createElement( "table");
_tbody=document .createElement( "tbody");
var _tr = document.create Element("tr");
var _td = document.create Element("td");
_td.innerHTML=" 6";
_td.id=""+x+"_" +y+"";
_td.setAttribut e("onclick",fun ction(){check(e vent);});
_tr.appendChild (_td);
_tbody.appendCh ild(_tr);
_table.appendCh ild(_tbody");
....
>
function check(e){
if (!e)
{
var e=window.event;
alert(e+" :None");
}
if (e.target)
{
targ=e.target;
alert("FF/Netscape: ");
}
else if (e.srcElement)
{
targ=e.srcEleme nt;
alert("IE");
document.getEle mentById(e.srcE lement.id).inne rHTML="0";
}
alert(targ.tagN ame);
}
Any help in tracking this problem would be really useful.
Comment