javascript - 为什么这段 JavaScript 代码在 Internet Explorer 中不起作用?

标签 javascript internet-explorer cross-browser internet-explorer-9

有人可以检查一下为什么我的 javascript 代码在 Internet Explorer 9 中无法工作,但在 Firefox 中却正常工作???此外,代码在 Google Chrome 中不起作用。

<html>
<head>
   <title>test</title>
   <script type="text/javascript">
      function showF4(){
      document.getElementById('showF4').style.display = "block";
   }
   </script>
</head>
<body>
   <form method="post" action="" enctype="multipart/form-data" method="post">
      <p><select class="selField" id="list_sel" name="list_type" >
         <option id="F4DOL" onmouseover="showForm7()" onmouseout="hideForm7()"            onclick="showF4()"  value="F4 Document List"> F4 Document List </option>

      </select></p>
   </form>

   <div id="showF4" style="display: none">
      <p><font color="red">*</font>Feature:
      <input   id="f4_input"  name="f4_input" type="text" value="" /> </p>
   </div>
</body>
</html>

最佳答案

<option id="F4DOL" onmouseover="showForm7()" onmouseout="hideForm7()" onclick="showF4()"  value="F4 Document List"> F4 Document List </option>

选项没有像onClick这样的事件,它的选择框有。将它们从 option 移出到 select 并更改为适当的方法,例如 onChange 等。

关于javascript - 为什么这段 JavaScript 代码在 Internet Explorer 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18712856/

相关文章:

JavaScript JQuery 触发器 ("click") 问题

javascript - 声明可在 Nodejs、浏览器、commonJS 和 AMD 中工作的 javascript 独立库的正确方法是什么?

internet-explorer - Visual Studio 2005 - 在不同的用户帐户下运行网站

javascript - 使用 JavaScript/jQuery 在 Chrome 中读取 mp3 文件持续时间

javascript - Flow react native导入图片报错cannot resolve module RelativeImageStub

javascript - 如何在我的 Ember 应用程序中包含 CLDR.js 库?

css - 悬停不适用于 ie9 中的嵌套 ul

internet-explorer - 使 Adob​​e 字体在 IE9 中与 CSS3 @font-face 一起工作

html - 如何在 css+html 中居中模态窗口?

javascript - Angular JS : Accessing a $scope. 变量在 $http.get block 内定义以在另一个 $http.get 中使用