[thelist] setAttribute setting events

Jeff Howden jeff at jeffhowden.com
Thu Nov 6 12:52:26 CST 2003


mike,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Mike Stenhouse
>
> I've been struggling with this for a day now and I just
> can't get it to work... What I'm trying to do is write
> a little script that will go through and collapse the
> text within each div.charge on the page and make the
> div's h3 a link to expand the content. I've got almost
> all of this working but I just can't find a way to make
> the setAttribute("onmouseup") work across the browsers.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

imo experience it's a bad idea to use setAttribute() to assign event
handlers to objects.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> I've tried about half a dozen methods of setting the
> attribute but none of them has worked for both IE and
> Moz. Could anyone help me???
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

yeah, you've got basically two choices.

1) use some switching code to attach the event handlers using browser
specific code.

or, if you know you'll not ever want to have other code run in addition to
this function call for this event handler....

2) use standard event handler anonymous function
   declaration:

   oDiv.onclick = function()
   {
     myFoo();
   }

good luck,

.jeff

------------------------------------------------------
Jeff Howden - Web Application Specialist
Resume - http://jeffhowden.com/about/resume/
Code Library - http://evolt.jeffhowden.com/jeff/code/



More information about the thelist mailing list