[thelist] javascript default event handlers, default events. [TIP]

Matt Warden mwarden at gmail.com
Wed Aug 31 06:19:43 CDT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kowalkowski, Lee (ASPIRE) wrote:
>>-----Original Message-----
>>From: Matt Warden [mailto:mwarden at gmail.com]
>>Sent: Tuesday, August 30, 2005 8:16 PM
>>
>>This is the equivalent of having inline CSS.
> 
> 
> No it isn't, having onsubmit="if(this.fieldName.value === ''){alert('you
> must enter something');return false;}" is the equivalent of having inline
> CSS.  A single method call is the equivalent of using a stylesheet.  

No, completely separating the JavaScript to <script></script> tags
would be the equivalent to using a stylesheet. Stylesheets use
selectors to apply style, just like your JavaScript example that you
dislike with document.myForm.onsubmit. You're basically saying the
JavaScript equivalent of:

<foo style="color: red;"> ... </foo>

is better than:

<foo style="color: red; font-weight: bold; text-align: center:
vertical-align: top; float: left;"> ... </foo>

To make it painfully clear:

stylesheet:

#foo {
	// style
}

javascript:

document.getElememtById('foo').onbar = handleBar; // no pun intended

>>That is not a markup reference. It has nothing to do with markup.
> 
> 
> How does it have nothing to do with markup?  If I have <form
> name="myForm">...</form>, how is document.myForm *not* a reference to it?
> I'd really like to know.

Nothing about document.myForm says that there is <form name="myForm"
...></form> markup in the document. It is referring to an element in
the document tree. It just happens to ALSO be possible to "add" by
"adding" in markup. But it's also possible a number of other ways, e.g.

var frm = document.createElement('form');
frm.name = 'myForm';
document.appendChild(frm);


- --
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFDFZJPAQ0d4HGyPE8RAlQCAJ4rEfr1uZqbmfXbZbiRFfGSi/l9mACfddEY
v2IY2xtMt2zSz9cjaozY4jI=
=lqdZ
-----END PGP SIGNATURE-----


More information about the thelist mailing list