R
Ron
Hi,
I'm using javascript to dynamically generate a table (ajax/xml).
What I want to achieve is when a table cell is clicked it needs to
call a function and pass the event as a parameter (In IE I can use the
window.event to access the event once the function is called, but in
Firefox it needs to be passed as a parameter.)
In normal html it would look like this:
<td onclick="javascript:fnSetSub(event)"></td>
to do this using javascript I've got something that looks like this:
var newTr = document.createElement('TR');
var newTd = document.createElement('TD');
newTd.onclick = function() {fnSetSub (event);};
newTr.appendChild(newTd);
but when the cell is clicked it comes up with an "e is undefined"
error in Firefox. I've tried using this.event, newTd.event but
nothing works. The function called looks something like this:
function fnSetSub (e) {
var targ;
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
}
Any help will be much appreciated.
Ron
I'm using javascript to dynamically generate a table (ajax/xml).
What I want to achieve is when a table cell is clicked it needs to
call a function and pass the event as a parameter (In IE I can use the
window.event to access the event once the function is called, but in
Firefox it needs to be passed as a parameter.)
In normal html it would look like this:
<td onclick="javascript:fnSetSub(event)"></td>
to do this using javascript I've got something that looks like this:
var newTr = document.createElement('TR');
var newTd = document.createElement('TD');
newTd.onclick = function() {fnSetSub (event);};
newTr.appendChild(newTd);
but when the cell is clicked it comes up with an "e is undefined"
error in Firefox. I've tried using this.event, newTd.event but
nothing works. The function called looks something like this:
function fnSetSub (e) {
var targ;
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
}
Any help will be much appreciated.
Ron