What happens is this:
You create the iFrame, then you add the event to DOC (which is empty), then
the load event is fired and DOC is set.
Events are asynchronous - that's the whole point.
the code should be:
load: function(){
DOC = this.contentWindow.document;
DOC.open();
DOC.write("<html><head></head><body>Hallo!</body></html>");
DOC.close();
DOC.designMode = 'on';
*DOC.addEvent('ketpress',function(){.....});*
load_toolbar();
}
On Thu, Sep 16, 2010 at 11:11 AM, gasmor <[email protected]> wrote:
> don't function...
>
> I write (keydown) in the window in iframe (DOC).
>
> code is:
>
> DOC.addEvent('keydown', function(event){ alert(event.key) });
>
> not
>
> myIFrame.addEvent('keydown', function(event){ alert(event.key) });
>
> On Sep 16, 8:56 am, "Steve Onnis" <[email protected]> wrote:
> > Why don't you add it into the events?
> >
> >
> >
> > -----Original Message-----
> > From: gasmor [mailto:[email protected]]
> > Sent: Thursday, 16 September 2010 4:54 PM
> > To: MooTools Users
> > Subject: [Moo] iframe keypress for firefox and Explorer
> >
> > Hi All,
> >
> > i have this code:
> >
> > window.addEvent('domready', function(){
> >
> > var myIFrame = new IFrame({
> >
> > styles: {
> > width: '100%',
> > height: '190px',
> > border: '1px solid
> > #333'
> > },
> >
> > id: "Composition",
> >
> > events: {
> > load:
> > function(){
> >
> DOC
> > = this.contentWindow.document;
> >
> > DOC.open();
> >
> > DOC.write("<html><head></head><body>Hallo!</body></html>");
> >
> > DOC.close();
> >
> > DOC.designMode = 'on';
> >
> > load_toolbar();
> > }
> >
> > }
> >
> > }).inject($('for_iframe'));
> >
> > DOC.addEvent('keydown', function(event){ alert(event.key) });
> >
> > });
> >
> > This code it's ok only in Chrome Browser but not in Firefox and IE.
>
--
Arieh Glazer
אריה גלזר
052-5348-561
5561