On Mar 4, 12:51 am, ohneworte <[EMAIL PROTECTED]> 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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---