按钮在第一次点击时没有响应

时间:2018-01-18 20:23:18

标签: javascript button onclick

我的网站标题中有一个按钮,它必须在第一次点击时打开/更改另一个div显示状态。但它在第一次点击时没有响应,我无法找到错误。我很感激帮助..



open System
open System.IO
open System.Linq
open System.Security.AccessControl
open System.Security.Principal

let checkSecurity  =
    let account = sprintf @"%s\%s" Environment.UserDomainName Environment.UserName
    let identity = WindowsIdentity.GetCurrent()
    let principal = identity |> WindowsPrincipal
    let isAdmin = identity.Owner = identity.User
    fun (dir: DirectoryInfo) ->
        try
            let acl = dir.GetAccessControl(AccessControlSections.All)
            let rules = acl.GetAccessRules(true, true, typeof<NTAccount>)
            rules.OfType<FileSystemAccessRule>() 
            |> Seq.filter (fun rule -> rule.IdentityReference.Value.Equals(account, StringComparison.CurrentCultureIgnoreCase) || 
                           (if rule.IdentityReference.Value.Equals("BUILTIN\Administrators", StringComparison.CurrentCultureIgnoreCase) 
                            then isAdmin && principal.IsInRole(rule.IdentityReference.Value)
                            else principal.IsInRole(rule.IdentityReference.Value)))
            |> Seq.exists (fun rule -> (rule.FileSystemRights &&& FileSystemRights.Read = FileSystemRights.Read) && rule.AccessControlType <> AccessControlType.Deny)
        with | _ -> 
            false

let rec getFiles (dir: DirectoryInfo) =
    [ if checkSecurity dir
      then for file in dir.GetFiles("*") do yield file
           for subDir in dir.GetDirectories("*") do yield! getFiles subDir
    ]

let dir = DirectoryInfo(@"C:\Temp")
dir |> getFiles
&#13;
/* show search div */
function ShowSearchDiv() {
  var searchbox = document.getElementById("header-search-form");
  if (searchbox.style.display === "none") {
    searchbox.style.display = "block";
    document.getElementById("search-icon").classList.remove('fa-search', 'fa-lg2');
    document.getElementById("search-icon").classList.add('fa-close', 'fa-lg-sm');

  } else {
    searchbox.style.display = "none";
    document.getElementById("search-icon").classList.remove('fa-close', 'fa-lg-sm');
    document.getElementById("search-icon").classList.add('fa-search', 'fa-lg2');
  }
}
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

我发现了错误并将if语句更改为:

&#13;
&#13;
<script>
/* show search div */
function ShowSearchDiv() {
    var searchbox = document.getElementById("header-search-form");
    if (searchbox.style.display === "block") {
        searchbox.style.display = "none";
          document.getElementById("search-icon").classList.remove('fa-close', 'fa-lg-sm');
          document.getElementById("search-icon").classList.add('fa-search', 'fa-lg2');  

      }
      else {
        searchbox.style.display = "block"; 
            document.getElementById("search-icon").classList.remove('fa-search', 'fa-lg2');
            document.getElementById("search-icon").classList.add('fa-close', 'fa-lg-sm');
         } 
}

</script>
&#13;
&#13;
&#13;

这种方式不是检查&#34;如果div被隐藏,那么让它可见,然后隐藏它......&#34;,我把它改为&#34;如果div是可见的,那么make它隐藏了,否则让它可见:) 现在它正在进行第一次点击。