Jason wrote:
Do not top-post, reply below a trimmed quote of the text you are
replying to.
> Still doesnt work...So i wrote a test script demoing the bug:
I've grown to rather dislike the term "bug", it is used to refer to any
behaviour that is contrary to that expected, whether it is the result
of an error or not. But anyhow, thank you for posting a concise
example.
>
> window.onload = function() {
> var table = document.createElement("table");
> table.style.width = "200px";
> table.style.height = "200px";
> table.style.border = "1px solid black";
> var row = table.insertRow(-1);
> var td = row.insertCell(-1);
> td.onclick = myfunction;
> document.body.appendChild(table);
> }
>
> function myfunction(e) {
> alert(e);
> alert(window.event);
> }
>
> Any ideas why e is undefined?
It is undefined in IE because you haven't assigned a value to it (read
my previous post again). The function I posted was (comment removed):
function myfunction(e) {
var e = e || window.event;
alert(e);
}
Notice the difference? The line:
var e = e || window.event;
might be easier to understand as:
if ( typeof e != 'object' && typeof window.event == 'object') {
e = window.event;
} else {
e = undefined;
}
but the former is considerably shorter.
--
Rob