S
Sri02
All,
I was trying to add an onclick event using setAttribute to a <td> from
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.createElement("tr");
var _td = document.createElement("td");
_td.innerHTML="6";
_td.id=""+x+"_"+y+"";
_td.setAttribute("onclick",function(){check(event);});
_tr.appendChild(_td);
_tbody.appendChild(_tr);
_table.appendChild(_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.srcElement;
alert("IE");
document.getElementById(e.srcElement.id).innerHTML="0";
}
alert(targ.tagName);
}
Any help in tracking this problem would be really useful.
I was trying to add an onclick event using setAttribute to a <td> from
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.createElement("tr");
var _td = document.createElement("td");
_td.innerHTML="6";
_td.id=""+x+"_"+y+"";
_td.setAttribute("onclick",function(){check(event);});
_tr.appendChild(_td);
_tbody.appendChild(_tr);
_table.appendChild(_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.srcElement;
alert("IE");
document.getElementById(e.srcElement.id).innerHTML="0";
}
alert(targ.tagName);
}
Any help in tracking this problem would be really useful.