0

I have the following script that creates and random number and writes it.

My Javascript for the random number is:

var number = Math.floor(Math.random() * 1000001);
if (number % 100 == 0) {} {
// Print the number
document.write(number);
}

I have several iframes and they all need random numbers. How do i get this to print a different number inside the iframe src attribute as shown below?

<iframe src="www.website.com?rng=[RANDOMNUMBER]"></iframe>

Thanks in advance.

4

1 回答 1

0

它真的必须是一个“随机”数字吗?为什么不使用像这样简单的东西:

for(var i = 0; i < 10; i++){    
     document.write("<iframe src='www.website.com?rng=" + i + "'></iframe>");
}
于 2013-10-02T15:42:05.430 回答