faqts : Computers : Programming : Languages : JavaScript : DHTML

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

23 of 25 people (92%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

ow do I dynamically change a style attribute in a CASCADED style element? (eg: elementRef.style.backgroundImage)

Aug 11th, 2000 09:50
Rey Nuņez, Pat Friedl,


IE4+ and NN6 allow dynamically changing style attributes using the 
basic DOM notation:
elementRef.style.propertyName
For example, to change a background image's source in response to mouse 
events:
onmouseover="this.style.backgroundImage = 'url(filepath/imagefile.jpg)'"
NN4 does not support the DOM style object, but allows changing the 
background image of content bound by its proprietory LAYER element.
document['layerRef'].background= 'imagefile.jpg'
For information on changing the background image of the BODY, plese see:
http://www.faqts.com/knowledge-base/view.phtml/aid/993/fid/126