ohneworte
2008-Mar-03 14:51 UTC
IE: don´t get element-focus if I enhancing the DOM-Tree via "Element.insert" or "appendChild()"
Hello together, does anyone know why IE does not focus on elements that are pasted in the DOM via Prototypes "Element.insert" or the JavaScript-Basic "appendChild()"? Following scenario: ------------------------------------------- <div id="pasteMeHere"> <span id="testFocus_1" tabindex="0" style="border:solid red">Focus me! </span> </div> <script> var test = document.createElement("span"); test.innerHTML = ''Focus me too!''; test.style.border = ''solid green''; test.setAttribute(''id'', "testFocus_2"); test.setAttribute(''tabindex'', ''0''); // Choose one of the following: // 1. Prototype-Way: NOT WORKING! $("pasteMeHere").insert({ bottom: test }); // 2. Basic JavaScript-Way: NOT WORKING! document.getElementById("pasteMeHere").appendChild(test // 3. Additional-Way: WORKING! document.write(''<span id="testFocus_2" style="border: medium solid green;" tabindex="0">Focus me too!</span>'') </script> ------------------------------------------- If I include my new span-Tag with the first or second method it is not possible to focus it via the tabulator. Thanks for any hints ... --~--~---------~--~----~------------~-------~--~----~ 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-Mar-03 16:09 UTC
Re: IE: don´t get element-focus if I enhancing the DOM-Tree via "Element.insert" or "appendChild()"
This looks like yet another IE bug to me. Did you try setting innerHTML? - kangax On Mar 3, 9:51 am, ohneworte <alexander.gewess...-Tswl7xcH0yE@public.gmane.org> wrote:> Hello together, > > does anyone know why IE does not focus on elements that are pasted in > the DOM via Prototypes "Element.insert" or the JavaScript-Basic > "appendChild()"? > > Following scenario: > > ------------------------------------------- > > <div id="pasteMeHere"> > <span id="testFocus_1" tabindex="0" style="border:solid red">Focus me! > </span> > </div> > > <script> > var test = document.createElement("span"); > test.innerHTML = ''Focus me too!''; > test.style.border = ''solid green''; > test.setAttribute(''id'', "testFocus_2"); > test.setAttribute(''tabindex'', ''0''); > > // Choose one of the following: > > // 1. Prototype-Way: NOT WORKING! > $("pasteMeHere").insert({ bottom: test }); > > // 2. Basic JavaScript-Way: NOT WORKING! > document.getElementById("pasteMeHere").appendChild(test > > // 3. Additional-Way: WORKING! > document.write(''<span id="testFocus_2" style="border: medium > solid green;" tabindex="0">Focus me too!</span>'') > </script> > > ------------------------------------------- > > If I include my new span-Tag with the first or second method it is not > possible to focus it via the tabulator. > Thanks for any hints ...--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ohneworte
2008-Mar-03 16:16 UTC
Re: IE: don´t get element-focus if I enhancing the DOM-Tree via "Element.insert" or "appendChild()"
Hmm, as you can see - innerHTML is set (test.innerHTML = ''Focus me too!'') --~--~---------~--~----~------------~-------~--~----~ 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-03 16:24 UTC
Re: IE: don´t get element-focus if I enhancing the DOM-Tree via "Element.insert" or "appendChild()"
I didn''t realize that you could focus non-form controls, such as a span. What purpose does this serve? -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 -~----------~----~----~----~------~----~------~--~---
RobG
2008-Mar-04 03:09 UTC
Re: IE: don´t get element-focus if I enhancing the DOM-Tree via "Element.insert" or "appendChild()"
On Mar 4, 12:51 am, ohneworte <alexander.gewess...-Tswl7xcH0yE@public.gmane.org> wrote:> Hello together, > > does anyone know why IE does not focus on elements that are pasted in > the DOM via Prototypes "Element.insert" or the JavaScript-Basic > "appendChild()"?Is this only for IE? According to the W3C DOM HTML specification, the only elements that have a focus method are: select, input, textarea and anchor. IE may allow you to focus other elements, but I would not count on it being consistent or supported in other browsers.> > Following scenario: > > ------------------------------------------- > > <div id="pasteMeHere"> > <span id="testFocus_1" tabindex="0" style="border:solid red">Focus me!The tabindex attribute is not valid for a span element, it is only valid for: a, area, button, input, object, select and textarea elements.> </span> > </div> > > <script> > var test = document.createElement("span"); > test.innerHTML = ''Focus me too!''; > test.style.border = ''solid green''; > test.setAttribute(''id'', "testFocus_2"); > test.setAttribute(''tabindex'', ''0'');You are setting a DOM property that is case sensitive, try: test.tabIndex = ''0''; It seems to be a good idea to use language features where they are faster, more reliable and require less typing - set properties directly. It may also lead to less confusion. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ohneworte
2008-Mar-04 10:38 UTC
Re: IE: don´t get element-focus if I enhancing the DOM-Tree via "Element.insert" or "appendChild()"
> You are setting a DOM property that is case sensitive, try: > > test.tabIndex = ''0'';I can´t believe it - how simple can a solution be? Thanks!> The tabindex attribute is not valid for a span element, theonly elements that have a focus method are: select, input, textarea and anchor That´s right, it´s not compliant to the current standards. But sometimes it is neccessary to focus more than the standard-elements - e.g.: if you are developing Rich Internet Applications. I refer to http://www.w3.org/TR/2007/WD-aria-state-20071019/#tabindex_added --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---