A
Adi
Okay, this issue has been annoying me for a little while now.
I need it to work on Mozilla 1.6 & IE 6
This is what I would like to be able to do:
var row = document.createElement("TR");
var tdImage = document.createElement("TD");
var img = document.createElement("IMG");
img.src = "results.gif";
var theA = document.createElement("A");
theA.setAttribute("href", "#");
//Hack which works in both IE6 and Mozilla 1.6
theA["onclick"] = new Function("myFunction(event, 'SomeThing')");
theA.appendChild(img);
tdImage.appendChild(theA);
row.appendChild(tdImage);
Function myFunction(e, theString){
alert(e);
alert(theString);
}
So I am creating a row to be inserted into a table tbody.
The A has a onclick handler.
I want the onclick handler to pass in the event object & some additional
parameters to the function specified.
Running the above gives me "event is not defined" on the:
theA["onclick"] = new Fu... line.
Where as:
<A HREF="#" onclick="myFunction(event, 'SomeThing');">Hello</A>
Works fine!
How do I pass in the elusive event via a dynamically created handler?
Thanks,
Adi.
I need it to work on Mozilla 1.6 & IE 6
This is what I would like to be able to do:
var row = document.createElement("TR");
var tdImage = document.createElement("TD");
var img = document.createElement("IMG");
img.src = "results.gif";
var theA = document.createElement("A");
theA.setAttribute("href", "#");
//Hack which works in both IE6 and Mozilla 1.6
theA["onclick"] = new Function("myFunction(event, 'SomeThing')");
theA.appendChild(img);
tdImage.appendChild(theA);
row.appendChild(tdImage);
Function myFunction(e, theString){
alert(e);
alert(theString);
}
So I am creating a row to be inserted into a table tbody.
The A has a onclick handler.
I want the onclick handler to pass in the event object & some additional
parameters to the function specified.
Running the above gives me "event is not defined" on the:
theA["onclick"] = new Fu... line.
Where as:
<A HREF="#" onclick="myFunction(event, 'SomeThing');">Hello</A>
Works fine!
How do I pass in the elusive event via a dynamically created handler?
Thanks,
Adi.