Is it possible to observe events in iframe? var iframe = new Element(''iframe''); iframe.observe(''mouseup'', function (e) { ... }); // Not works ;-( I found that in FF, I can iframe.contentWindow.document.addEventListener(''mouseup'', function (e) {...}, true); // Works But, how to do it with Prototype? tnx --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Not exactly. As you can see from your example, the iframe''s content is literally a different document, with its own namespace. So if Prototype were loaded in the iframe''s document, you could say iframe.contentWindow.document.observe(...). -Fred On Tue, Jun 24, 2008 at 7:53 AM, AlannY <m@alanny.ru> wrote:> > Is it possible to observe events in iframe? > > var iframe = new Element(''iframe''); > > iframe.observe(''mouseup'', function (e) { ... }); // Not works ;-( > > I found that in FF, I can > > iframe.contentWindow.document.addEventListener(''mouseup'', function (e) > {...}, true); // Works > > But, how to do it with Prototype?-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You should observe the window inside the frame, the code is something like this: function contentWindow(frame){ if(Prototype.Browser.IE) return frame.contentWindow.document; return frame.contentDocument.defaultView; } contentWindow = contentWindow($(''my_frame'')); Event.observe(contentWindow, ''click'', function(e){/*...*/}); -- blog: www.lucaguidi.com Pro-Netics: www.pro-netics.com Sourcesense - making sense of Open Source: www.sourcesense.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Firefox says: contentWindow.observe is not a function ;-) Like before ;-( On Jun 24, 5:03 pm, Luca Guidi <guidi.l...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You should observe the window inside the frame, the code is something > like this: > > function contentWindow(frame){ > if(Prototype.Browser.IE) > return frame.contentWindow.document; > return frame.contentDocument.defaultView; > > } > > contentWindow = contentWindow($(''my_frame'')); > Event.observe(contentWindow, ''click'', function(e){/*...*/}); > > -- > blog:www.lucaguidi.com > Pro-Netics:www.pro-netics.com > Sourcesense - making sense of Open Source:www.sourcesense.com--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
contentWindow.observe isn''t a function because A) it''s in the other frame and you haven''t loaded Prototype into it, and B) because the window object probably isn''t extended anyway. The code below uses Event.observe(...contentWindow), not contentWindow.observe(). -Fred On Wed, Jun 25, 2008 at 10:03 AM, AlannY <m@alanny.ru> wrote:> > Firefox says: > contentWindow.observe is not a function ;-) Like before ;-(-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Is Prototype loaded to the iframe automaticaly, or I should load manually? If second: how to do it? On Jun 24, 5:00 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:> Not exactly. As you can see from your example, the iframe''s content is > literally a different document, with its own namespace. So if Prototype > were loaded in the iframe''s document, you could say > iframe.contentWindow.document.observe(...). > > -Fred > > On Tue, Jun 24, 2008 at 7:53 AM, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote: > > > Is it possible to observe events in iframe? > > > var iframe = new Element(''iframe''); > > > iframe.observe(''mouseup'', function (e) { ... }); // Not works ;-( > > > I found that in FF, I can > > > iframe.contentWindow.document.addEventListener(''mouseup'', function (e) > > {...}, true); // Works > > > But, how to do it with Prototype? > > -- > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The body of the iframe document would need to have the <script> tag for Prototype. -Fred On Wed, Jun 25, 2008 at 10:07 AM, AlannY <m@alanny.ru> wrote:> > Is Prototype loaded to the iframe automaticaly, or I should load > manually? If second: how to do it? > > On Jun 24, 5:00 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: > > Not exactly. As you can see from your example, the iframe''s content is > > literally a different document, with its own namespace. So if Prototype > > were loaded in the iframe''s document, you could say > > iframe.contentWindow.document.observe(...). > > > > -Fred-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
As Frederick said, you cannot invoke #observe on contentWindow, because it isn''t a Prototype extended element. You should use Event.observe syntax. Luca -- blog: www.lucaguidi.com Pro-Netics: www.pro-netics.com Sourcesense - making sense of Open Source: www.sourcesense.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I was playing with #extendIframe method some time ago http://github.com/kangax/protolicious/tree/master/element.methods.js#L186 Unfortunately, it only works in FF/Safari (need to find some time to tackle the problems in IE/Opera) - kangax On Jun 25, 11:07 am, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote:> Is Prototype loaded to the iframe automaticaly, or I should load > manually? If second: how to do it? > > On Jun 24, 5:00 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: > > > Not exactly. As you can see from your example, the iframe''s content is > > literally a different document, with its own namespace. So if Prototype > > were loaded in the iframe''s document, you could say > > iframe.contentWindow.document.observe(...). > > > -Fred > > > On Tue, Jun 24, 2008 at 7:53 AM, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote: > > > > Is it possible to observe events in iframe? > > > > var iframe = new Element(''iframe''); > > > > iframe.observe(''mouseup'', function (e) { ... }); // Not works ;-( > > > > I found that in FF, I can > > > > iframe.contentWindow.document.addEventListener(''mouseup'', function (e) > > > {...}, true); // Works > > > > But, how to do it with Prototype? > > > -- > > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thank you all ;-) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Be cautious of listening to the iframe''s document, if that iframe refreshes, its a brand new document, and in that case your listener is lost, so you''d have to listen to the load event and grab a fresh reference to stay persistent. -- Matt Foster Ajax Engineer Nth Penguin, LLC http://www.nthpenguin.com On Jun 25, 2:16 pm, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote:> Thank you all ;-)--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Still not works ;-( var iframe_doc; if( Prototype.Browser.IE ) { iframe_doc = iframe.contentWindow.document; } else { iframe_doc = iframe.contentDocument.defaultView; } Event.observe(iframe_doc, ''click'', function (e) { alert("click"); }); On Jun 24, 4:53 pm, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote:> Is it possible toobserveevents iniframe? > > variframe= new Element(''iframe''); > > iframe.observe(''mouseup'', function (e) { ... }); // Not works ;-( > > I found that in FF, I can > > iframe.contentWindow.document.addEventListener(''mouseup'', function (e) > {...}, true); // Works > > But, how to do it with Prototype? > tnx--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I have search on the NET and seems that there are exists some bugs in FF with iframs''s onfocus event, which I need ;-) But it not works even in IE ;-( I''m not loading the page of iframe from the outside, so, maybe, it''s better to load Prototype in the iframe? On Jun 26, 7:53 pm, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote:> Still not works ;-( > > var iframe_doc; > if( Prototype.Browser.IE ) { > iframe_doc = iframe.contentWindow.document;} else { > > iframe_doc = iframe.contentDocument.defaultView; > > } > > Event.observe(iframe_doc, ''click'', function (e) { alert("click"); }); > > On Jun 24, 4:53 pm, AlannY <m...-I/IS3f7Pe4GHXe+LvDLADg@public.gmane.org> wrote: > > > Is it possible toobserveevents iniframe? > > > variframe= new Element(''iframe''); > > > iframe.observe(''mouseup'', function (e) { ... }); // Not works ;-( > > > I found that in FF, I can > > > iframe.contentWindow.document.addEventListener(''mouseup'', function (e) > > {...}, true); // Works > > > But, how to do it with Prototype? > > tnx--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---