setTimeout()没有运行?

时间:2015-02-08 17:51:24

标签: javascript jquery

var account;
var users = ["********"];
var password = "*********";
var gameId = 126945035 //Put your game ID here

for (account = 0; account < users.length; account++) {
    window.location.assign('www.roblox.com');
    $(document).ready(function(){
        document.getElementById("LoginUsername").value = users[account];
        document.getElementById("LoginPassword").value = password;
        document.getElementById('LoginButton').click();
        setTimeout(function(){
        window.location.assign('http://www.roblox.com/Game/PlaceLauncher.ashx?request=RequestGame&placeId=' + gameId);
            setTimeout(function(){
            window.location.assign('http://www.roblox.com/---place?id=' + gameId);
                $('.upvote').click();
            }, 1000);
        }, 1000);
    });
};

当我运行它时,它应该登录到帐户,这似乎正在工作,但在我使用setTimeout()后,它不会在那之后运行任何东西。

所有*都是我无法分享的信息。

1 个答案:

答案 0 :(得分:0)

这是因为您将当前网页留在第一个setTimeout中。这不是由setTimeout功能引起的,而是您离开网页的事实。

Location.assign()方法导致窗口加载并显示URL参数的页面。

这基本上意味着,当您解雇window.location.assign('url')时,您强制重新加载页面。这会阻止处理任何其他代码行。

你可能想要

a)发出ajax请求以初始化您的身份验证过程

b)使用传统的回发请求在会话中存储第一个url请求的状态。然后,工作流程中访问的第二页将具有适当的凭据。

相关问题