|  | IE support of javascript setAttribute('style', ... ) |  | |
| | | bgold12 |  |
| Posted: Mon Sep 01, 2008 1:42 pm Post subject: IE support of javascript setAttribute('style', ... ) |  |
Does internet explorer support the statement elem.setAttribute('style', ... );, for example:
document.getElementById('ExampleID').setAttribute('style', 'width: 10px' );
I can't get that statement to work in IE7, although it works in FF3.
bgold12 |
| |
| | | Joost Diepenmaat |  |
| Posted: Mon Sep 01, 2008 1:42 pm Post subject: Re: IE support of javascript setAttribute('style', ... ) |  |
bgold12 <bgold12@gmail.com> writes:
| Quote: | Does internet explorer support the statement elem.setAttribute('style', ... );, for example:
|
That would be a confusing statement: does it completely replace all current styles or what? Note that FF (at least FF 2) does not allow you to replace the style, so elem.style = ... will throw an error.
You probably want just elem.style.backgroundColor= ... and equivalent instead.
-- Joost Diepenmaat | blog: LINK | work: LINK |
| |
| | | Arun |  |
| Posted: Mon Sep 01, 2008 2:43 pm Post subject: Re: IE support of javascript setAttribute('style', ... ) |  |
| |  | |
On Sep 1, 2:46 pm, Joost Diepenmaat <jo...@zeekat.nl> wrote:
| Quote: | bgold12 <bgol...@gmail.com> writes: Does internet explorer support the statement elem.setAttribute('style', ... );, for example:
That would be a confusing statement: does it completely replace all current styles or what? Note that FF (at least FF 2) does not allow you to replace the style, so elem.style = ... will throw an error.
|
I disagree. Firefox has support for both forms of *style* manipulation. You can change the object's complete style description using the setAttribute(attrName, attrValue) method. But, for the sake of browser compatibility what you suggested below is more apt.
| Quote: | You probably want just elem.style.backgroundColor=... and equivalent instead.
|
On another note, Firefox has another way of manipulating attributes which is a bit daunting. I was so hoping that IE had it. But 6 and 7 don't support proper attribute manipulation I might say.
document.getElementById(id).attributes.item("style").nodeValue "color:red";
IE8x, I hope would resolve these issues.
Arun |
| |
|
|