日期:2014-05-16  浏览次数:20346 次

帮忙看看这段JS在火狐下为什么不能用,怎么改,才能兼容火狐
HTML code

<!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=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript">
function FunCheckCosts()
     {
        //不为空的文本框的ID
        if (!CheckFields("name,pwd"))
        {
          alert("信息必须填写完整!");
          return false;
        }
}

function CheckFields(txtChecks)
{
   var oArray = txtChecks.split(",");
   for (var i=0;i<oArray.length;i++)
   {

     if (document.getElementById(oArray[i]).value.replace(/\s/g,"") == "")
      {
        try { document.getElementById(oArray[i]).focus(); }
        catch (e) {}
        event.returnValue = false;
        return false;
      }
   }
     return true;
}
</script>
</head>

<body>
<form action="" method="post" onsubmit="return FunCheckCosts()">
<input type="text" name="name" id="name" />
<input type="text" name="pwd" id="pwd" />
<input type="submit" name="button" value="提交" />
</form>
</body>
</html>





------解决方案--------------------
event.returnValue = false;
去掉,非IE不存在 event对象