Спасибо, но отображает почему-то "3.3.112".
Привожу полный код скрипта на всякий случай:
<script type="text/javascript">
<!--
var console = window.console || {log : function(msg) {alert(msg);}},
MYAPP = MYAPP || {
cookie : {
expireDate : function(periodType, offset) {
var expire = new Date();
switch (periodType.toLowerCase()) {
case 'years':
expire.setFullYear(expire.getFullYear() + offset);
break;
case 'months':
expire.setMonth(expire.getMonth() + offset);
break;
case 'days':
expire.setDate(expire.getDate() + offset);
break;
case 'hours':
expire.setHours(expire.getHours() + offset);
break;
case 'minutes':
expire.setMinutes(expire.getMinutes() + offset);
break;
default:
console.log(
'MYAPP.cookie.expireDate( Invalid "periodType" = "' + periodType + '" );'
);
}
return expire;
},
deleteCookie : function (cookieName) {
writePersistentCookie(cookieName, 'Pending delete', 'years', -1);
},
getCookieValue : function (cookieName) {
var exp = RegExp(cookieName + '=([^;]+)');
if (exp.exec(document.cookie + ';')) {
return RegExp.$1;
}
return null;
},
writePersistentCookie : function (cookieName, cookieValue, expire, path) {
var expire = expire || this.expireDate('minutes', 5),
path = path || '/';
document.cookie = cookieName + '=' + cookieValue
+ '; expires=' + expire.toUTCString()
+ '; path=' + path;
}
},
showRandomId : function(id, range, periodType) {
var getRandomId = function() {
var cookieName = 'random_id',
value = MYAPP.cookie.getCookieValue(cookieName),
expire = MYAPP.cookie.expireDate(periodType[0], periodType[1]),
x = range[0],
y = range[1],
random = Math.floor( Math.random() * (y - x + 1) ) + x,
sep = '&';
if(value) {
value = value.split(sep);
} else {
value = [random, expire.valueOf()];
MYAPP.cookie.writePersistentCookie(cookieName, value.join(sep), expire);
}
return value;
},
value = getRandomId(),
date = new Date(+value[1]),
obj = document.getElementById(id);
if(obj) {
obj.innerHTML = '<p>Специальный номер: <em>' + value[0]
+ '</em> истекает <em>' + date.getDate()+'.'+date.getMonth()+'.'+date.getYear() + '</em></p>';
}
}
}
-->
</script>
</head>
<body onload="MYAPP.showRandomId('container', [10101, 99988], ['days', 3])">
<span id="container"></span>