|
|
 |
FN-FORUM: Problem with getElementById and Mac IE
date posted 11th May 2006 12:25
Hi, can someone with some Javascript / DOMscripting knowledge please
help:
I'm trying to update the background image of a div (id="bannerRight")
using some scripting. The stylesheet sets one image as the div
background and when the page loads I want to load a different one in
(this'll be from a random selection, but I've left that code out as it's
not the problem.) What I've done works OK in Firefox, Safari and IE6,
but I can't get it working in Mac IE, where instead of loading another
image it just removes the original image and doesn't load a new one.
The problem seems to be with this bit of code, which I presume I've got
wrong somehow:
document.getElementById('bannerRight').style.backgroundImage =
"url('images/2.jpg')";
All the page source is below if that helps. I'd like to either get it
working in Mac IE, or just get that browser to ignore what I'm trying to
do and to leave the original image in place.
Any help gratefully received!
Cheers
Paul
Random background
#bannerRight {
width: 400px;
height: 200px;
background-image: url('images/test.jpg');
background-repeat: no-repeat;
}
function randomBanner() {
if (document.getElementById) {
document.getElementById('bannerRight').style.backgroundImage
= "url('images/2.jpg')";
}
}
Random Background
Blah
Blah
--
Paul Silver - Web Development and Technical Search Engine Optimisation
07813 654285 -- http://www.paulsilver.co.uk
Check your web pages: http://www.spidertest.com
|
 |
|