警报在IE 8中不起作用

Alert not working in IE 8

本文关键字:不起作用 IE      更新时间:2024-04-01

在我的web应用程序中,我在jsp文件中添加了javascript
Firefox中弹出警报消息。但是警告窗口在IE 8中不起作用。以下是我正在使用的javascript
有人能告诉我如何在IE 8中实现这一点吗?

 function doSubmit() {
        var checkbox = document.getElementById("terms");
        if (!checkbox.checked) {
          alert("error message goes here.");
          return false;
      } else {
      return true;
      }
    }

运行良好,以下是使用方法!

<html>
<head>
<script type="text/javascript">
    function doSubmit() {
        var checkbox = document.getElementById("vehicle");
        if (!checkbox.checked) {
          alert("error message goes here.");
          return false;
      } else {
        return true;
      }
    }
</script>
</head>
<body>
    <form name="frm1" onsubmit=" return doSubmit()">
        <input type="checkbox" name="vehicle" value="Bike" />Checked<br />
        <input type="submit" value="Submit" />
    </form>
</body>
</html>

根据建议添加了更正。