Hi,
I gather that Javascript standard function names are case sensitive
and they follow the old Smalltalk manner of applying case e.g.
thisName,
however I am curious, I see "onerror" mentioned on some web pages
which seems to contradict the standard. Or is it actually onError?
Thanks.
HTML is case-insensitive: so are its tag names, so are tags' attribute
names. This way one may write
<BODY ONERROR="...
<body onerror="...
<BoDy OnErRoR="... etc.
There are some oftenly seen ways to use the case, say to capitalize
the name of the event, sometimes capitalize both "On" and the event
name though the latter is now considered as an old style of writing:
<body onError="... or <body OnError="...
HTML itself doesn't care, it is all the question of particular habits.
In the older school it was common to capitalize the opening tag but to
use lower case for the closing tag, plus to capitalize "On" and event
names, so by seeing a source like:
<BODY OnError="myFunction()">
<H1>Hello!</h1>
and similar one may assume that it is made by an old geezer (by the
Web's time scale) or by someone pretending to be such old geezer.
From the other side Javascript is a case-sensitive language,
respectively window.onerror, window.onError, window.ONERROR etc are
all different for it with only the first one having the same effect as
<body onerror=... and anything else just adding extra property to the
window object.
That means that from the practical point of view it is better to stick
to the lowercased version of event handler names: that will prevent
possible typos in your script, when say you are typing window.onLoad
because you have used to it in your body element - and then you cannot
understand why it doesn't work.
Of course it is not a rule of any kind - just a suggestion.