本帖最后由 gaozhi0 于 2009-12-28 11:22:07 编辑

解决方案 »

  1.   

    if(clientip4<=ipn[3]){
       alert("yes too too too!");
    }
    这一行判断应该执行的,却没有执行,因为clientip4<=ipn[3]返回false,这两个变量是我前面已经赋值了的
      

  2.   


    var a="35",b="255";
    alert(a<b);
    alert((a-0)<(b-0));//-0转化 为int
      

  3.   

    这个可以,
    或者加上parseInt()
                    if(parseInt(clientip3)<=parseInt(ipn[2])){
                        alert("yes too too");
                        alert("clientip4:"+clientip4+"    ipn[3]:"+ipn[3]);
                                                 
                        alert(clientip4<=ipn[3]);
                        if(clientip4<=ipn[3]){
                            alert("yes too too too!");
                        }
                    }
      

  4.   

    //clientip4=35,ipn[3]=255,但是下面的对话框弹出的竟然是false,if判断也没执行。
    被你注释掉了
    改为clientip4=35;
        ipn[3]=255;
    试下
      

  5.   

    应该是其他地方的问题,调用。测试没问题啊,在数组比较时最好加上parseInt()<script>
    var test=function(){
    var clientip1=35;var ipn=new Array();
    ipn[0]=50;
    ipn[1]=100;
    ipn[2]=200;
    ipn[3]=255;
    if(clientip1<=parseInt(ipn[0])){
    alert("yes")
    if(clientip1<=parseInt(ipn[1])){
    alert("yes too");
    if(clientip1<=parseInt(ipn[2])){
    alert("yes too too");
    alert("clientip4:"+clientip1+"    ipn[3]:"+parseInt(ipn[3]));
      //clientip4=35,ipn[3]=255,但是下面的对话框弹出的竟然是false,if判断也没执行。
    alert(clientip1<=parseInt(ipn[3]));
    if(clientip1<=parseInt(ipn[3])){
    alert("yes too too too!");
    }
    }
    }
    }
    }();</script>
      

  6.   

    //clientip4=35,ipn[3]=255,但是下面的对话框弹出的竟然是false,if判断也没执行
    这一行是我写给你们看的,不是程序里面的代码,是我的错,写在这个位置你们都以为是代码
    问题已经解决,我的疑问是为什么我其他的判断也是这样写:if(clientip1<=ipn[0])。
    为什么就只有这一个判断有问题呢,想不通。
      

  7.   

    也许你其他地方判断时:clientip1 和ipn[0] 已经转化为 数值类型了,而这个函数中是 字符,
    而且你说的"其他地方判断时没问题" 可能也有问题,因为clientip1 和ipn[0]假如用的的是字符,也是可以判断
    例如:
    <script>
        function b(){
         var a = "A";
         var b = "3";
        if(a>b){
           alert("true");
        }      
        }
    </script>
    <input  type  = "button" value = "dddd" onclick= "b();"/>
    </script>
    结果是“true”