如下代码:要求在fireox下脚本可以运行,参数必须是this求教大牛们......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript" src="Script/jquery-1.6.2.min.js"></script>
<link rel="stylesheet" type="text/css" href="Css/StockAuto.css" />
<script type="text/javascript">
function test()
{ if(data.value!=""){
  alert("x");
}
}
</script>
</head><body>
<input type="text"  id="txtOn" onclick="test(this)"/><br />
<input name="" type="button" value="确定" />
</body>
</html>

解决方案 »

  1.   

    用jquery
    function test()
    { if($(data).val()!=""){

      alert("x");
    }
    }
    这样判读都不行- -
      

  2.   

    js的
    <script type="text/javascript">
    function test(data)
    {if(data.value!=""){
    alert("x");
    }
    }
    </script>JQ的
    <script type="text/javascript">
    function test(data)
    {if($("#"+data.id).val()!=""){
    alert("x");
    }
    }
    </script>
      

  3.   

    function test(obj) {
        if(obj.value != ""){
            alert(obj.value);
        }
    }原生的js就可以,根本不需要jq
      

  4.   


    <script type="text/javascript">
    function test(o)
    {
    if(!o.value)
    alert("非空");
    else
    alert("空值")
    }
    </script>那你要按钮干嘛的??
      

  5.   

    怎么不行,同样的代码,我IE7、8,FF都测了可以的啊
      

  6.   

    汗,js不是神,它显然不明白data是个什么东西,你得告诉它
      

  7.   

    楼主你的方法都没有参数,这样应该可以
    function test(obj) {        if (obj.value != "") {
                alert(obj.value);
            }
        }
      

  8.   

    function test(data)
    {if(data.value!=""){
    alert("x");
    }
    }
      

  9.   

    最好别用test这样的javascripgt的内置函数名称
      

  10.   

    楼主你的那个onclick属性加给的是文本框诶!这样按钮就没有用处了哦!
      

  11.   

    不明白楼主为什么要传this参数,一下代码楼主可以测试下可以得到你需要的功能。
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="javascript" type="text/javascript" src="Script/jquery-1.6.2.min.js"></script>
    <link rel="stylesheet" type="text/css" href="Css/StockAuto.css" />
    <script type="text/javascript">
    function test()
    {
    var txt=document.getElementById('txtOn');
    if(txt.value!=""){
    alert("x");
    }
    }
    </script>
    </head><body>
    <input type="text" id="txtOn" /><br />
    <input name="button" type="button" value="确定" onclick="test()"/>
    </body>
    </html>