d_idaho
2008-Mar-12 11:53 UTC
Prototype: extending elements with Element object in an iframe seems not working
Hi, I just started learning prototype, and I encountered a problem while trying to use Element.extend with iframe content: / **********************************************************************/ // I create an iframe and insert it in my document: var iframe = $(document.createElement("iframe")); document.getElmentsByTagName("body")[0].appendChild(iframe); // I create content in for my new iframe: iframe.contentDocument.write("<html><head></head><body></body></ html>"); // I get the iframe body element: var body = iframe.contentDocument.getElementsByTagName("body"); //I create a div element in the iframe, and extend it with Element properties: var div = $(document.createElement("div")); // I insert the div element in the iframe body: body.appendChild(div); // Then I try to absolutize the position of my div element... div.absolutize(); // ... and I get the following error message: // div.absolutize is not a function // If I try to use the depreciated Position object... Position.absolutize(div); // ...then I got another interesting error message: // element.getStyle is not a function // which is an error that occurs in the absolutize Element method call // absolutize: function(element) { // element = $(element); // -----> if (element.getStyle(''position'') =''absolute'') return; / ***********************************************************************/ It seems that when I insert the element in the iframe, then it is not anymore able to be extended with Element methods and properties... Did anyone ever meet this kind of problem? How did you issue? Thanks, D_idaho --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Justin Perkins
2008-Mar-12 16:26 UTC
Re: Prototype: extending elements with Element object in an iframe seems not working
On Wed, Mar 12, 2008 at 6:53 AM, d_idaho <adesmulier-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> iframe.contentDocument.write("<html><head></head><body></body></html>");I was not aware that you could do these kinds of things to an iframe, but it appears that you can with iframes that are created by the parent window. Interesting. I think the main problem you are running into is that everything in the iframe has been sandboxed away from the parent, so none of the prototype methods that you are expecting to be there, will be there. -justin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---