I would consider myself to be reasonably competent with JavaScript and familiar with many of the different ways of achieving the same thing. But today I came across some function syntax which I hadn't seen before:
function document.body.onload()
{
alert('loaded');
}
If I were to write such code I would have done it like this:
document.body.onload = function()
{
alert('loaded');
}
Ignoring the fact that this is not the best way to handle the onload
event, is this actually valid JavaScript? It appears to causes syntax errors in FireFox (and JSLint), so I am guessing that it is Internet Explorer only syntax? If it is IE only then I would like to remove it but I am concerned that it might have some quirky side effect.