簡體   English   中英

為什么此html代碼復選框適用於Firefox和Chrome,但不適用於IE?

[英]Why this code for html checkbox works for Firefox and Chrome, but not for IE?

這與我以前的問題有關: 為什么html復選框功能僅在IE中起作用,而在Firefox或Chrome中卻不起作用?

為什么以下代碼在IE中不起作用:

<body>

<script type="text/javascript">
  function checkAdvSearch(checked)
  {
    console.log("Test");
    if (checked==1)
    {
      document.getElementById("searchTerm2").style.display='';
      document.getElementById("searchField2").style.display='';
    }
    else
    {
      document.getElementById("searchTerm2").style.display='none';
      document.getElementById("searchField2").style.display='none';

      document.getElementById("searchTerm2").value='';
      document.getElementById("searchField2").value='Client Name';
    }
  }
</script>

  <input type="checkbox" name="advSearch" onclick="checkAdvSearch(this.checked);" checked />Advanced Search
  <input type="text" id="searchTerm2" value="" />
  <select id="searchField2" value="clientName" >
    <option>Client Name</option>
    <option>Policy Number</option>
  </select>

</body>
</html>

當我取消選中該框時,其他2項應該消失了,但是在IE中沒有響應,為什么?

編輯:

感謝Huangism,我找到了以下消息,並單擊它允許訪問,現在它可以正常工作了。

在此處輸入圖片說明

通過允許IE阻止內容解決了問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM