broberts
2008-Apr-23 21:44 UTC
Get a reference to the BODY tag node with no ID or class attribute
Is there a way to get a reference to the BODY tag node in the DOM if it has no class or ID attribute by which to select it? I want to insert a dynamically created node right before the closing body tag. Here''s where I was going, but I''m not sure how to reference the BODY tag node. var body_tag = ? var speaker_div = new Element(''div'', { ''id'': ''my_div'', ''style'': ''width: 1px; height: 1px;'' }).insert(body_tag, { position: ''bottom'' }); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
broberts
2008-Apr-23 21:47 UTC
Re: Get a reference to the BODY tag node with no ID or class attribute
Just document.body? I was thinking Prototype might have a cross- browser compatible method... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Brian Williams
2008-Apr-23 21:48 UTC
Re: Get a reference to the BODY tag node with no ID or class attribute
er... couldn''t you just do something like... var speaker_div = new Element(''div'', { ''id'': ''my_div'', ''style'': ''width: 1px; height: 1px;'' }) document.write(speaker_div) ? On Wed, Apr 23, 2008 at 5:44 PM, broberts <broberts80-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Is there a way to get a reference to the BODY tag node in the DOM if > it has no class or ID attribute by which to select it? > > I want to insert a dynamically created node right before the closing > body tag. Here''s where I was going, but I''m not sure how to reference > the BODY tag node. > > var body_tag = ? > > var speaker_div = new Element(''div'', { ''id'': ''my_div'', ''style'': > ''width: 1px; height: 1px;'' }).insert(body_tag, { position: ''bottom'' }); > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
broberts
2008-Apr-23 22:02 UTC
Re: Get a reference to the BODY tag node with no ID or class attribute
Bryan, Thanks. I ended up answering my own question. I didn''t actually need to insert before the BODY tag like I had originally thought. As for your comment about document.write, I was concerned that I might encounter some cross-browser compatibility issues that Prototype might have already overcome. On Apr 23, 4:48 pm, "Brian Williams" <brianw1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> er... couldn''t you just do something like... > > var speaker_div = new Element(''div'', { ''id'': ''my_div'', ''style'': > ''width: 1px; height: 1px;'' }) > > document.write(speaker_div) > > ? > > On Wed, Apr 23, 2008 at 5:44 PM, broberts <brobert...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Is there a way to get a reference to the BODY tag node in the DOM if > > it has no class or ID attribute by which to select it? > > > I want to insert a dynamically created node right before the closing > > body tag. Here''s where I was going, but I''m not sure how to reference > > the BODY tag node. > > > var body_tag = ? > > > var speaker_div = new Element(''div'', { ''id'': ''my_div'', ''style'': > > ''width: 1px; height: 1px;'' }).insert(body_tag, { position: ''bottom'' });--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
broberts
2008-Apr-23 22:06 UTC
Re: Get a reference to the BODY tag node with no ID or class attribute
Sorry.. "Brian" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
kangax
2008-Apr-23 22:06 UTC
Re: Get a reference to the BODY tag node with no ID or class attribute
Check out this patch by jdalton for a multi document support [1] If iframes are out of the question, then "document.body" should do just fine. [1] http://dev.rubyonrails.org/ticket/11475 - kangax On Apr 23, 5:44 pm, broberts <brobert...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is there a way to get a reference to the BODY tag node in the DOM if > it has no class or ID attribute by which to select it? > > I want to insert a dynamically created node right before the closing > body tag. Here''s where I was going, but I''m not sure how to reference > the BODY tag node. > > var body_tag = ? > > var speaker_div = new Element(''div'', { ''id'': ''my_div'', ''style'': > ''width: 1px; height: 1px;'' }).insert(body_tag, { position: ''bottom'' });--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
broberts
2008-Apr-24 15:15 UTC
Re: Get a reference to the BODY tag node with no ID or class attribute
Thanks kangax. Thankfully I''m not trying to insert into an iframe this time around, but Ive taken note of the patch in case I do in the future. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jdalton
2008-Apr-24 15:29 UTC
Re: Get a reference to the BODY tag node with no ID or class attribute
document.body is cross browser i believe. you can always do $(document.body) to have it extended or a more expensive $$(''body'') - JDD --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---