On 31/12/2007, asmason <anthony-6uYP6wzbvIsqdlJmJB21zg@public.gmane.org>
wrote:>
> Hi all,
>
> I noticed on the Prototype site,
http://www.prototypejs.org/api/event#method-observe,
> that Prototype 1.6 defines instance methods on the event objects.
>
> I tried it out, and unless I am mistaken, it does not work in IE6.
>
> default.htm
> ----------------
> <input type="button" name="btn" id="btn"
value="click me" />
>
> default.js
> ----------------
> Event.observe(window, ''load'', init);
>
> function init(){
> Event.observe(''btn'', ''click'',
respondToClick);
> }
>
> function respondToClick(event) {
> //ok
> //var element = Event.element(event);
> //element.addClassName(''foo'');
>
> //not in IE6
> var element = event.element();
> element.addClassName(''foo'');
> }
>
> styles.css
> ----------------
> .foo {border: 1px solid red;}
This seems to work OK. Tested on IE7/FF2.0.0.10 on WinXPSP2
<html>
<head>
<title>Test HTML</title>
<script src="http://prototypejs.org/assets/2007/11/6/prototype.js"
type="text/javascript"></script>
<style type="text/css">
.foo {border: 1px solid red;}
</style>
<script type="text/javascript">
document.observe(
''dom:loaded'',
function(){
$(''btn'').observe(
''click'',
function(e){
e.element().addClassName(''foo'');
}
);
}
);
</script>
</head>
<body>
<input type="button" name="btn" id="btn"
value="click me" />
</body>
</html>
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---