Linuxhippy
03-21-2005, 01:42 PM
Hello!
I have the following problem: I want to set the background-attribute of an div-element via javascript and this works well for all browsers I tested except: IE6.
I found out that the event-method is never called, but I do not find my mistake :-(
If I replace the the setActive-call with "alert('Hello!');" everything works fine. I am quite confused...
Please help...
Thank you in advamce, lg Clemens
Here's the code:
<script type="text/javascript">
<!--
function setActive(elementName, active)
{
alert("Hallo!");
var element = document.getElementById(elementName);
if(active)
{
element.style.backgroundImage = "url(images/img_base.png)";
}else
{
element.style.backgroundImage = "url(images/black.png)";
}
}
-->
</script>
.............
somewhere later in body:
<div id="div1"
onMouseOver="setActive('div1', true);"
onMouseOut="setActive('div1', false);"
style="background-image:url(images/black.png); background-repeat:repeat-y; background-color:#000000;">
<P ALIGN="CENTER" style="margin:0px;">
<a HREF="topangebote%20maerz.htm" TARGET="_blank"> some text
</a>
</P>
</div>
I have the following problem: I want to set the background-attribute of an div-element via javascript and this works well for all browsers I tested except: IE6.
I found out that the event-method is never called, but I do not find my mistake :-(
If I replace the the setActive-call with "alert('Hello!');" everything works fine. I am quite confused...
Please help...
Thank you in advamce, lg Clemens
Here's the code:
<script type="text/javascript">
<!--
function setActive(elementName, active)
{
alert("Hallo!");
var element = document.getElementById(elementName);
if(active)
{
element.style.backgroundImage = "url(images/img_base.png)";
}else
{
element.style.backgroundImage = "url(images/black.png)";
}
}
-->
</script>
.............
somewhere later in body:
<div id="div1"
onMouseOver="setActive('div1', true);"
onMouseOut="setActive('div1', false);"
style="background-image:url(images/black.png); background-repeat:repeat-y; background-color:#000000;">
<P ALIGN="CENTER" style="margin:0px;">
<a HREF="topangebote%20maerz.htm" TARGET="_blank"> some text
</a>
</P>
</div>