On Oct 26, 2:41 pm, Cliff <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a button like this: <a id="btn1">some button</a>
> This code works in safari and firefox, but fails in IE6: $
> ('btn1').writeAttribute('onclick', "alert(123)");
> The onclick event does not fire in IE6.
>
> What should I do?

Assign a function reference to `onclick` directly:
$('btn1').onclick = function(){ alert(123) };

> I know Event.observe is better, but I want to use variables to pass a
> function, e.g.
>   var functionslist = "alert(123); alert(321)";
>   $('btn1').writeAttribute('onclick', functionslist);

Not sure I understand. Why exactly can't you do this with
`Event.observe`?

$('btn1').observe('click', function() {
  alert(123);
  alert(321);
});

>
> Thanks!

--
kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to