简体   繁体   English

为什么此javascript代码在Internet Explorer中不起作用?

[英]Why doesn't this javascript code work in Internet Explorer?

Can someone check why my javascript code isn't working in Internet Explorer 9, but works normally in Firefox ??? 有人可以检查为什么我的JavaScript代码在Internet Explorer 9中不能正常运行,但是在Firefox中可以正常运行吗? Also code doesn't work in Google Chrome. 另外,代码在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>

option s don't have those events like onClick , its the select box that does. option没有像onClick这样的事件,它的选择框没有。 Move those out of option to select and change to appropriate methods like onChange etc. 将其移出optionselect并更改为适当的方法,例如onChange等。

So I found the following: 所以我发现以下内容:

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

And one of the guys gave this as the answer 有人给了这个答案

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. 

Have a look, it might solve your problem 看看,它可能会解决您的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么此Dojo 1.9 / JS代码在Internet Explorer 7中不起作用? - Why doesn't this Dojo 1.9/JS code work in Internet Explorer 7? 为什么querySelector(JavaScript)无法与Internet Explorer一起使用? - Why the querySelector (JavaScript) doesn't work with Internet Explorer? 为什么我的代码在Internet Explorer上不起作用? - Why my code doesn't work on Internet Explorer? javascript 在 Internet Explorer 上不起作用 - javascript doesn't work on internet explorer Mixitup Javascript 在 Internet Explorer 中不起作用 - Mixitup Javascript doesn't work in Internet Explorer 为什么基于setTimeout的代码不能在Firefox中以很小的超时时间运行(在Internet Explorer / Chrome中运行)? - Why doesn't this setTimeout-based code work in Firefox with a small timeout (works in Internet Explorer/Chrome)? dispatchEvent 在带有 Internet Explorer 11 的 javascript 中不起作用 - dispatchEvent doesn't work in javascript with Internet explorer 11 我的滚动处理程序JavaScript在Internet Explorer中不起作用 - My scroll handler JavaScript doesn't work in Internet Explorer 为什么我的Twitter按钮在Internet Explorer 7中不起作用? - Why doesn't my Twitter button work in Internet Explorer 7? 为什么此网页不能仅在Internet Explorer中工作? - Why doesn't this webpage work in Internet Explorer only?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM