1

有人可以检查为什么我的 javascript 代码不能在 Internet Explorer 9 中运行,但在 Firefox 中运行正常吗???代码在谷歌浏览器中也不起作用。

<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>
4

2 回答 2

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

options 没有那些事件,例如onClick,它的选择框。将它们移出optionselect更改为适当的方法,例如onChange等。

于 2013-09-10T07:27:24.257 回答
0

所以我发现了以下内容:

http://www.webmasterworld.com/forum91/4959.htm

其中一个人给出了这个答案

hi, 
your method of setting the style of elements: 

element.style.property="something";

will not work in ie. How to set styles with javascript depends not only on the browser, but in some cases also on other conditions, as if the style is inline or comes from css and on other things (for this see eg. quirksmode.org).
Therefore you might prefer to add styles for a specific class in your stylesheet, let's say 

.noshow {visibility: hidden;}

and then use js to switch between visible and not by saying 

element.className="noshow";

and 

element.className="";

Hope this helps. 

看看吧,或许能解决你的问题

于 2013-09-10T07:31:37.000 回答