How to pause execution for a while (similar to a "wait" or "sleep")?

4

This code is working and running under an existing account on this site , what I want to do is: Add a pause, a type of While , Wait , Sleep or ReadyState , after login and before going to the new tab. This line would replace the window.close() line.

<html>
    <head>
      <title>L2 CR AUTO LOGIN</title>
    </head>
    <body>
      <form id="loginForm" name="loginForm" method="post"    action="http://zionweb.l2cr.com/gamecpc6/index.php">
        <select name="uni_url" id="logServer" class="validate[required]">
          <option  class=""  value="http://zionweb.l2cr.com/gamecpc6/index.php" fbUrl=""  cookieName=""  >
             Personagem1
          </option>
        </select>
        <input id="username" name="username" type="text" value="CHECKBOSS" class="" />
        <input id="password" name="password" type="password" value="123456" class="" />
        <input type="hidden" id="loginKid" name="kid" value=""/>
        <button onclick="myFunction()">Enter</button>
      </form>

      <script> function myFunction() {
         document.loginForm.submit(); 
         window.close();
         window.open("http://zionweb.l2cr.com/gamecpc6/classes/view_templates/rbs.php");    
      } </script>
    </body>
</html>
    
asked by anonymous 25.12.2015 / 05:22

1 answer

3

As it was not specified if you login to an ajax or an api, I would leave a simple solution, but not the most advisable, you can use setTimeout to determine a time to execute a function x, but I believe which is the most advisable in this case and analyze which is the possible callback of ajax / api to be able to perform another action.

setTimeout(alerta, 3000); // segundo parámetro e o timing para executar a função 



function alerta() {
  alert("LOL");
}
    
25.12.2015 / 05:55