该代码实现右下角窗口的功能,IE下没有问题,但在FF下就不行了,请问怎么解决呢?<html>
<head>
<script language="JavaScript" type="text/javascript">
            function $(obj){
                return document.getElementById(obj);
            }
            function pop(obj){
                var h = parseInt($("popDiv").currentStyle.height);
                $("popDiv").style.height = (h + obj) + "px";
                if(parseInt($("popDiv").style.height) < 2){
                    window.clearInterval(timer);
                    $("popDiv").style.display = "none";
                }
                if(parseInt($("popDiv").style.height) >= 200){
                    window.clearInterval(timer);
                }
        
            }
            
            var timer;
            function runtimer(obj){
                timer = window.setInterval(function(){pop(obj)},10);
            }
            window.onload = function(){
                runtimer(2);
            }
        </script></head><body >
<div style="position:absolute;right:0;bottom:0;height:0px;width:200px;border:1px solid red;" id="popDiv">
        <a href="javascript:runtimer(-2);">×</a>
        </div></body>
</html>

解决方案 »

  1.   

    function currentStyle(element) {
    return element.currentStyle || document.defaultView.getComputedStyle(element, null);
    }var h = parseInt($("popDiv").currentStyle.height);
    // --->>>
    var h = parseInt(currentStyle($("popDiv")).height);
      

  2.   

    $("popDiv").currentStyle is undefined
    改成
    $("#popDiv").currentStyle 
      

  3.   

    var h = parseInt($("popDiv").currentStyle.height);
    ===>
    var h = parseInt($("popDiv").style.height);
      

  4.   


    $("popDiv").style.height;//这个是什么?js还是jqueryjs是这样写的document.getElementById("popDiv").style.heightjquery 是这样的$("#popDiv").height();