当前位置: 代码迷 >> JavaScript >> 2个脚本之间的间隔
  详细解决方案

2个脚本之间的间隔

热度:75   发布时间:2023-06-13 11:55:12.0

 javascript:var settings = Array(0, 0, 'A', 0, 0, -100, 0, 0, 'A', 0, 0, 1, 'none', 'none', 'attack'); $.getScript( 'https://media.innogamescdn.com/com_DS_DE/scripts/qb_main/scriptgenerator.js'); setTimeout(function () { document.getElementById("troop_confirm_train").click(); document.getElementById("troop_confirm_train").click(); document.getElementById("troop_confirm_train").click(); (frames.main||self).document.forms[0].submit.click(); },1000); 

我现在有这个。 它没有按我的要求工作。 如果单击此按钮,它仍然仅执行第一个脚本。 但是,如果我第二次单击它,我感觉到1000毫秒的延迟...我希望这种情况只需单击一下即可发生。这可能吗?

可能有效。

 var settings = ... setTimeout(function() { void(0);document.getElementById... }, YOUR_TIMEOUT_IN_MILLISECS); 

假设您希望脚本的第二部分在加载远程脚本之后运行,那么可以使用的第二个参数来定义在脚本加载后运行的回调:

var settings = Array(0, 0, 'A', 0, 0, -100, 0, 0, 'A', 0, 0, 1, 'none', 'none', 'attack');

$.getScript(
    'https://media.innogamescdn.com/com_DS_DE/scripts/qb_main/scriptgenerator.js',
    function () {
        document.getElementById("troop_confirm_train").click();
        document.getElementById("troop_confirm_train").click();
        document.getElementById("troop_confirm_train").click();
        (frames.main||self).document.forms[0].submit.click();
    }
); 
  相关解决方案