JRS: In article <bk*******************@news.demon.co.uk>, seen in
news:comp.lang.javascript, Richard Cornford
<Ri*****@litotes.demon.co.uk> posted at Fri, 19 Sep 2003 02:44:41 :-
Generally it is unwise to use element names, IDs or JavaScript
identifiers that correspond with existing defined properties within the
browser object model, especially properties of the global object. Though
your specific problem would only manifest itself in browsers that follow
IE in making named/IDed HTML elements named properties of the global
object, unfortunately quite a number of browsers (including Opera 7) do.
Unfortunately, that otherwise-excellent rule requires a knowledge of all
such existing properties in all such browsers, including those that may
be written after the page in question.
A more pragmatic approach is never to use a name (except in a scope
where a new definition certainly rules) that anyone might, reasonably or
moderately unreasonably, build or have built into a system.
It seems that most lesser-known names in javascript begin with a lower-
case letter; so one could avoid that.
Also, it is commonly convenient when programming to do a general string
search or replace on a page or a page set. Therefore, avoid correctly-
spelt well-known words in the natural language of the page, and in HTML.
Once upon a time, at least one system designer understood this problem.
In software for the Elliott 905, names beginning with Q-but-not-QU
"belonged" to the system software authors. They could be used by
ordinary programmers; they could be redefined, but only at the
programmer's understood risk. All other names were either not used by
the system, or were "well-known".
And in implementations of Algol, "reserved words" were indicated by
punctuation; in some, the word begin was coded as "begin" or
'begin'; in another, as !begin, and then reserved words could be
abbreviated once unambiguous - so !begin could be !be. but not (if
!boolean existed) !b. .
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.