Hi guys, I''m trying to get the Width value of a element using the getWidth() functions in prototype. My Code looks like this: var width = $(''myElement'').firstChild.getWidth(); This code works fine in FX but not in IE, strange as It seems! On the other hand, this code, not pointed to an child element works fine in both browsers. var width = $(''myElement'').getWidth(); And for your information, this code also works in both browsers. And my question is, isn''t this exactly how the getWidth() function works? var width = $(''myElement'').firstChild.offsetWidth; Can someone help me solve this problem. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
HI, Try: var width = $(''myElement'').down().getWidth(); And read-up oin element extension here: http://prototypejs.org/learn/extensions BEst, Tobie On Feb 6, 8:09 am, mng0 <ggus...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi guys, > > I''m trying to get the Width value of a element using the getWidth() > functions in prototype. > > My Code looks like this: > > var width = $(''myElement'').firstChild.getWidth(); > > This code works fine in FX but not in IE, strange as It seems! > > On the other hand, this code, not pointed to an child element works > fine in both browsers. > > var width = $(''myElement'').getWidth(); > > And for your information, this code also works in both browsers. And > my question is, isn''t this exactly how the getWidth() function works? > > var width = $(''myElement'').firstChild.offsetWidth; > > Can someone help me solve this problem.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Tobie, Thanks for the fast reply! I guess that works, but I solved the problem on my own ;) I tried the firstDescendant() function instead of firstChild and now it works in both browsers. Anyways, now I want a function that is opposed to lastChild DOM property, I''m sure this function must exist but I''m to blind, can''t find it in the documentation, please give me a hint. Start reading the about extensions now... Regards mng0 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
aah, the link you gave me solved my problem. // this will error out in IE: $(''someElement'').lastChild.getWidth() // to make it cross-browser: $($(''someElement'').lastChild).getWidth() Thanks anyway! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---