Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » JavaScript

IE support of javascript setAttribute('style', ... )

 
Jump to:  
 
bgold12
PostPosted: 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
PostPosted: 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
PostPosted: 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
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

bingo Parkiet Wynajem samochodów ubezpieczenie oc Quotations