有以下一个样式和两个函数
<style type="text/css">
     body {
     margin-top: 0px;
     margin-left: 0px;
     width: 100%;
          }
</style><script type="text/javascript">
function mouseOver()
{
    source=event.srcElement;
    source.style.background="url(images/gisbutton1.png)";
}

function mouseOut()
{
    source=event.srcElement;
    source.style.background="url(images/gisbutton2.png)";
}
</script>
 
在IE8里面浏览没有任何问题,但是在火狐浏览器里边样式表中的width=100%似乎不起作用,而且两个js函数也不起作用,请问这是为什么?

解决方案 »

  1.   

    这位大哥
    body加上100%有什么含义呢?
      

  2.   

    re:1楼
    设置body的宽度为100%使其在浏览器上没有两边的空白,也就是占满整个window对象区域
      

  3.   

    firefox中没有event,试试这样看function mouseOver()
    {
       var event = arguments[0]||window.event;  
       source=event.srcElement;
       source.style.background="url(images/gisbutton1.png)";
    }function mouseOut()
    {
       var event = arguments[0]||window.event;  
       source=event.srcElement;
       source.style.background="url(images/gisbutton2.png)";
    }
      

  4.   

    function mouseOver(e)
    {
        e = e || event;
        var source = e.srcElement || e.target;
        source.style.background="url(images/gisbutton1.png)";
    }function mouseOut(e)
    {
        e = e || event;
        var source = e.srcElement || e.target;
        source.style.background="url(images/gisbutton2.png)";
    }
      

  5.   

    谢谢3楼和4楼的回答,不过都没能解决我的问题,还是一样在IE里面看没问题,Firefox就不行了
      

  6.   


    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>mydiv</title>
    <style type="text/css" rel="Stylesheet">
      body {
    margin-top: 0px;
    margin-left: 0px;
    width: 100%;
      }
    </style> <script type="text/javascript">
    function mouseOver(e){
    var event = e || event;
    var source=event.srcElement || e.target;
    source.style.background="url(images/1.png)";
    } function mouseOut(e){
    var event = e || event;
    var source=event.srcElement || e.target;
    source.style.background="url(images/2.png)";
    }
    </script>
    </head>
    <body>
    <div style="position:absolute;left:100px;top:100px;width:200px;height:200px;border:solid 1px black;" onmouseover="mouseOver(event);" onmouseout="mouseOut(event)"></div>

    </body>
    </html>
    各种浏览器测试都通过了. lz的原因可能是鼠标划过的地方被其他div覆盖了. 没有触发到mouseOver和mouseOut, LZ检查一下各种样式. 可以在函数第一句alert一下看进入到此函数没