TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   SetAttribute not working (http://forums.techarena.in/software-development/1110794.htm)

Xan 27-01-2009 01:24 PM

SetAttribute not working
 
i was working with some coding but i found my self in trouble when i got that setAttribute is not working. i used in internet explorer 6,7 but not working please anyone can help me to find out what is wrong ?

opaper 27-01-2009 01:30 PM

Re: SetAttribute not working
 
This is probably because IE considers setAttribute as setting the property of the actual javascript object. By setting the style attribute on a node, IE interprets it as setting node.style, which is not the actual attribute (node.style being an array of the different css settings instead). That's also why you can't set the 'class' or 'for' attributes, because on a element object, the old method of setting class and the for attribute are node.className and node.htmlFor.


When calling the DOM method .setAttribute( attName, attValue ); in IE, there are several circumstances where it will not work.
Setting the "name" attribute does not work, the "colspan" & "rowspan" attributes for th and td tags does not work, the "frameborder" attribute on iframes does not work.

karunakar 27-01-2009 01:32 PM

Re: SetAttribute not working
 
Using the DOM Methods to build up new content for your page, be aware that in IE, you can't pre-check a radio button or a checkbox using .setAttribute('checked', 'checked'); or even myCheckBoxObject.checked = true; *unless* you add the element to the page first.


All times are GMT +5.5. The time now is 06:29 PM.