大家好,请问js还可以用别的方式实现math.floor的功能吗(因项目实际原因,必须改写)?要改写的话函数该如何写?

解决方案 »

  1.   

    直接改写就可以了 给你看个例子:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>DOM Range Example</title>
    <style type="text/css"> 
    .my_table{position:absolute;top:100px;left:80px;height:200px;width:200px;border:1px solid #158bbf;background:#e0e0e0} 
    </style> 
    <script language="javascript"> 
    function alert(n){
    document.write(n)
    }
    window.onload=function() {alert("asdfasd")};
     
    </script> </head>
    <body>
       <input type="checkbox" forcheckboxgroup="abc">A <br> 
     &nbsp;   <input type="checkbox" group="abc">a <br> 
     &nbsp;   <input type="checkbox" group="abc">b <br> 
     &nbsp;   <input type="checkbox" group="abc" disabled="disabled">c <br> </body></html>
      

  2.   

    楼上的,你上面发的跟math.floor()函数好像没有关系吧,我是要一个其它的代码来实现这样的功能
      

  3.   

    你不是说要改写math.floor 函数得嘛我给你的是个改写window.alert 函数的  -_-
      

  4.   


    <script type='text/javascript'> 
    function Math.floor(num){
      return 1;
    }var i=90;alert(Math.floor(i));
    </script> 
      

  5.   

    Math.floor = function () {
    return "4444444";//这里写你自己的功能
    };
    alert(Math.floor());
      

  6.   

    恐怕楼主不要那样的功能把 
    那样做了有什么,呵呵  ,要那么做直接原型覆盖就可以了 提示楼主,可以采用字符传操作:直接截取小数点前的数字即可,那就是Math。floorMath,ceil 加一步,判断后面数字是否大于等于5就可以 ,大于的话+1