On 05/07/06, ecentinela gmail.com <ecentinela gmail.com> wrote:
>
> I have a script to make hotkeys on my web. I have to
"register" the
> onkeypress on the body on a page.
> If I make the tipical "<body
onkeypress='myfunction();'>" it works, but
> I want to change this for using behaviour.
> I don't know if this is posible, because I'm making
>
------------------------------------------------------------
-----
> var myrules = {
> 'body' : function(element){
> element.onkeypress = function(e){
> alert("hi");
> }
> }};
> Behaviour.register(myrules);
>
------------------------------------------------------------
-----
> and this is not working!
Are you using a Gecko based browser? Your script works fine
on the
other browsers I tried. It seems that Gecko based browsers
stores the
body's onkeypress event in the window object. I believe
this is
non-standard, although I'm not sure.
Anyway, I think the normal way to do this it to use
'document.onkeypress'. Since 'document' is always
available you can do
this outside of Behaviour:
document.onkeypress = function(e) {
alert("hi");
}
Daniel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Behaviour Javascript Library"
group.
To post to this group, send email to behaviour googlegroups.com
To unsubscribe from this group, send email to
behaviour-unsubscribe googlegroups.com
For more options, visit this group at http://group
s.google.com/group/behaviour
-~----------~----~----~----~------~----~------~--~---
|