cascading style sheets properties knowledge base
Cascading Style sheet won't change with javascript ? ok can you change a property of an elment with javascript if you have the style predefined beforehand in an external styesheet? I would assume yes, but my background image for some reason will not change. html code: <div valign="center" style="height:17px"> <td id="centerofpage" class="meat" width=864 height=800 valign ="center" style="height:800px;"> <table valign="center" cellspacing=0 cellpadding=0 border=0 style="top:1000px;"> and then when a user clicks a button to change the background. The background image for the whole body changes and then the background image for this element which is basically a big box with all the main content of the page in this box on the center of the page. here is the javascript code for that: document.getElementById('centerofpage').style.backgroundImage="url(/img/wall paper/Clouds.jpg)"; these images load fine as I can set the background image in CSS to be this image and it loads fine, but for some reason JS won't work. oops the Javascript code is: document.getElementById('centerofpage').style.backgroundImage="url(/img/wall paper/Clouds.jpg)"; uggg .style.backgroundImage="url(/img/wall paper/Clouds.jpg)" ok correctiojn this code does work fine in Internet Explorer, I just checked. But it won't work in Opera or Firefox nope I do need the url in the javascript function. Just tried omitting it and it caused IE not to work.
Powered by Yahoo! Answers