我有以下情况:
setTimeout("alert('this alert is timedout and should be the first');", 5000);
alert("this should be the second one");
我需要在 setTimeout
之后的代码在执行 setTimeout 中的代码后执行。由于 setTimeout
之后的代码不是我自己的代码,所以我不能将它放在 setTimeout 中调用的函数中…
有没有办法解决?
原文由 Nathan 发布,翻译遵循 CC BY-SA 4.0 许可协议
代码是否包含在函数中?
在这种情况下,您可以阻止该函数进一步执行,然后再次运行它: