本文介绍了无法获取随机数以用于setTimeout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎根本无法使我的Random#正常工作-代码将无法执行:(

Can't seem to get my Random # to work at all - code won't execute :(

function getRandomInt (5000, 10000) {
return Math.floor(Math.random() * (10000 - 5000 + 1)) + 5000;
}

setTimeout(Greasemonkey_main, getRandomInt);

function Greasemonkey_main () {
unsafeWindow.submitform(0);
unsafeWindow.submitform(1);
unsafeWindow.submitform(2);
unsafeWindow.submitform(3);
}

谢谢

推荐答案

getRandomInt()具有语法错误.使用该功能的标准版本

That getRandomInt() has syntax error(s). Use the standard version of that function!

因此代码将变为:

setTimeout (Greasemonkey_main, getRandomInt (5000, 10000) );

function Greasemonkey_main () {
    unsafeWindow.submitform(0);
    unsafeWindow.submitform(1);
    unsafeWindow.submitform(2);
    unsafeWindow.submitform(3);
}

function getRandomInt (min, max) {
    return Math.floor (Math.random () * (max - min + 1) ) + min;
}

这篇关于无法获取随机数以用于setTimeout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 21:54