[thelist] flipping backgrounds of elements in IE/NS ??
Moniruvwe Orife
moni at teamsphere.com
Mon Jul 9 17:42:27 CDT 2001
Hello all,
I tried to write a javascript function that changes the background image of
an element like a td or a div. I wrote the following code, but i'm having
trouble getting the actual image reference for an element. Can anyone offer
any help? Thanks.
------------------------------------------------------
code:
------------------------------------------------------
<html>
<head>
<style>
#thiscellDiv {
background-image:url(images/check_light.gif);
}
#other {
font-family:arial,verdana;
}
</style>
<script language=JavaScript>
ns6 = (document.getElementById) ? true : false;
nav = (document.layers) ? true : false;
iex = (document.all) ? true : false;
count = 1;
function changebg(){
if (count == 1){
document.getElementById("thiscellDiv").style.background-image.src =
images/check_medium.gif;
count = 0;
}
else {
document.getElementById("thiscellDiv").style.background-image.src =
images/check_light.gif;
count = 1;
}
}
</script>
</head>
<body marginheight=0 marginwidth=0 topmargin=0 leftmargin=0 rightmargin=0>
<div id=thiscellDiv>Aussi, jai appris que les Français sont des gens
logiques. Dans Le Discours sur la Méthode, on peut voir la pensée
rationnelle de Descartes. Il dit quil va employer toute sa vie à cultiver
sa raison. Il va faire une revue sur les diverses occupations quont les
hommes en cette vie. Il va choisir la meilleure....</div>
<div id=other><a href=# onclick="changebg(thiscellDiv);">Change the bg
please...</a></div>
</body>
</html>
------------------------------------------------------
end code
------------------------------------------------------
More information about the thelist
mailing list