T
The Natural Philosopher
Tim said:The Natural Philosopher said:After reading that 3 times, it almost makes sense.Henry said:On Oct 18, 4:03 pm, Randy Webb wrote:
GArlington said the following on 10/18/2007 9:51 AM:
<snip>
So when he/she runs the script document.getElementsByName('foo')[0]
refers to the FUNCTION foo and generates the error trying to access
attribute value which function WILL NOT have...
No, it doesn't. The function is not executed until you click on the
bold text in the original, the button in the latter. And, before
it is dreamed about, changing it back to a bold element didn't
make any difference either.
The code will not error on IE until someone puts the form elements
into a FORM element. At that point IE augments the scope chain of the
function that it creates from the intrinsic event attribute, and it
places the FORM element on that augmented scope chain. Thus when the
Identifier - foo - is resolved against this augmented scope chain an
object on the chain above the global object is found to have a 'foo'
property and the resulting value of - foo - is the value of that
property of the FORM element and not the global function.
I wouldnt know. My interest is avoiding pitfalls. Not becoming an expertEverybody else assumes that Javascript is included in head of the
page and so do NOT experience any errors.
Voodoo programming. Putting my script block before the closing body
tag had no impact on errors. I still don't get one.
It certainly is an odd proposition that moving the code into the HEAD
would make any difference.
in a language I really think is rather badly written.
When I started, there was code that was easy to read and code that was
hard to understand.
Then suddenly everyone started waffling about 'structured programming'.
After a while I realized this was an academic term for what we had all
been doing anyway. Making code easy to read.
Well, to be fair, not everyone had been doing that. It takes discipline
to make code easy to read, and easy to maintain, particularly if you
expect it to be part of a bigger package that will be handed over to
others to look after. While at CERN, I once saw a FORTRAN subroutine
written by a physicist for an analysis program. It was 50 pages of code,
when printed out on the fanfold paper of the time.
I had little confidence that it was fit for purpose.
Indeed.
Hardest part is prevent programmers being too clever and getting them to
document what they are doing.
The the latest bollocks was 'object oriented'. But of course with
backwards compatiblity to procedural. Oh and lets throw typing away cots
its too hard for numpties.
Result is a fucking plate of spaghetti where to change three bytes in a
browser takes in interpreted variable name with more dots than a
golfball covered in brackets and completely impenetrable, since its
scope is implementation dependent, and, worse depends on where it sits
in some HTML as well.
I am coming to realise that Javascript is possibly the worst language I
have ever had to program in.
Your post made me chuckle and its no bad thing for pompous language
types to be needled from time to time. But I don't think JS *quite*
deserves this level of opprobrium.
Perl, on the other hand, does. That's a much shittier language than JS,
so feel free to mosey on over to their NG.
Ah PERL I agree its even worse BUT I did say 'that I have ever programmd
in' after sacking a bloke who spent a year not doing what would have
taken me less than three weeks in 'C' , and realising that the little
bits he HAD done were so slow as to make the whole project completely
inviable, I decided never to touch PERL if it could be avoided. To date
here has always been an alternatve.
And remember: poor programmers can write FORTRAN in any language.
Nothing wrong with fortran.
I wish there was a macro so I could compress GetElementById into gebd()
or somesuch.
Maybe there is? <"brightens visibly">