首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

帮忙看看这段JS在火狐上为什么不能用,如何改,才能兼容火狐

2012-07-30 
帮忙看看这段JS在火狐下为什么不能用,怎么改,才能兼容火狐HTML code!DOCTYPE html PUBLIC -//W3C//DTD X

帮忙看看这段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对象

热点排行
Bad Request.