<script>
function On_M(obj)
{
    obj.style.background='images/r04.gif';
}
function On_O(obj)
{
    obj.style.background='images/r03.gif';
}
</script>
<div onmousemove="On_M(this);" onmouseout="On_O(this);" style="background-image:url('images/r03.gif'); width:149px; height:27px; margin-top:1px;" >
</div>这样子为啥出错...
obj.style.background=url('images/r04.gif');也是错

解决方案 »

  1.   

    给div加个id和name试试:
    <div  id="mydiv" name="mydiv" onmousemove="On_M(this);" onmouseout="On_O(this);" style="background-image:url('images/r03.gif'); width:149px; height:27px; margin-top:1px;" >
      

  2.   

    <script>
    function On_M(obj)
    {
        document.getElementById(obj).style.background='images/r04.gif';
    }
    function On_O(obj)
    {
        document.getElementById(obj).style.background='images/r03.gif';
    }
    </script>
    <div id="it" onmousemove="On_M(this.id);" onmouseout="On_O(this.id);" style="background-image:url('images/r03.gif'); width:149px; height:27px; margin-top:1px;" >
    </div>如果用this,只是获得一个object,所以会出错~
      

  3.   

    function On_M(obj)
    {
    obj.style.backgroundImage='url(images/r04.gif)';
    }
    function On_O(obj)
    {
    obj.style.backgroundImage='url(images/r03.gif)';
    }
    这样估计也可以
    {
    obj.style.backgroundImage="url('images/r04.gif')";