我正在用检查元素四处寻找并遇到了这个:
NumberOfDivsToRandomDisplay = 10;
var CookieName = 'DivRamdomValueCookie';
function DisplayRandomDiv() {
var r = Math.ceil(Math.random() * NumberOfDivsToRandomDisplay);
if (NumberOfDivsToRandomDisplay > 1) {
var ck = 0;
var cookiebegin = document.cookie.indexOf(CookieName + "=");
if (cookiebegin > -1) {
cookiebegin += 1 + CookieName.length;
cookieend = document.cookie.indexOf(";", cookiebegin);
if (cookieend < cookiebegin) {
cookieend = document.cookie.length;
}
ck = parseInt(document.cookie.substring(cookiebegin, cookieend));
}
while (r == ck) {
r = Math.ceil(Math.random() * NumberOfDivsToRandomDisplay);
}
document.cookie = CookieName + "=" + r;
}
for (var i = 1; i <= NumberOfDivsToRandomDisplay; i++) {
document.getElementById("randomdiv" + i).style.display = "none";
}
document.getElementById("randomdiv" + r).style.display = "block";
}
DisplayRandomDiv();
它的目的是什么?只是好奇,谢谢:)