HighDots Forums  

Replacing inline javascript and event handlers for stricter code.

alt.html.dhtml alt.html.dhtml


Discuss Replacing inline javascript and event handlers for stricter code. in the alt.html.dhtml forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Woolly Mittens
 
Posts: n/a

Default Replacing inline javascript and event handlers for stricter code. - 02-01-2005 , 03:12 PM






This post is triggered by the alistapart posting about the same thing. I
had been using the technique for some time. It really cleans up the code.

By applying certain classnames, you can parse the document and add event
handlers after loading, without having to clutter your HTML with script.
Imaging having this in you code:


<dt class="link classMouseHover toggleNextNode">
click this to open definition 1
</dt>
<dd class="hideThisNode">
Lorem ipsum dolor sit amet.
</dd>


Instead of all this:


<dt
onclick="objNode0.style.display=(objNode0.style.di splay=='none')?'block':'none';">
click this to open definition 1
</dt>
<dd id="hidethis0">
Lorem ipsum dolor sit amet.
</dd>
<script type="text/javascript">
var objNode0 = document.getElementById('hidethis0');
objNode0.style.display = 'none';
</script>


Check out the examples at:
http://www.woollymittens.nl/content/...lassbehaviour/

Greeting,
Woolly

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.