求救,高手帮下忙!!!在线等
请高手帮忙改一下下面的代码,让它在页面刷新时,时间还会继续走,不会又从头开始?
<style type= "text/css ">
#oTime {
color: blue;
font-size: 12px;
}
</style>
<script language= "javascript ">
var _t;
var _h = 2;
var _m = 0;
var _s = 0;
var _v = formatTime(_h + ': ' + _m + ': ' + _s);
function doTime() {
_s --;
if (_s == -1) {
_m --;
_s = 59;
}
if (_m == -1) {
_h --;
_m = 59;
}
var _b = ((_h == 0) && (_m == 0) && (_s == 0));
if (_b) {
_v = 'Welcome To IECN.NET ';
clearTimeout(_t);
} else {
_v = formatTime(_h + ': ' + _m + ': ' + _s);
_t = setTimeout( 'doTime() ', 1000);
}
document.all[ 'oTime '].innerHTML = _v;
}
function formatTime(_time) {
return _time.replace(/\b(\w)\b/g, '0$1 ');
}
onload = function() {
document.all[ 'oTime '].innerHTML = _v;
_t = setTimeout( 'doTime() ', 1000);
}
</script>
<span id= "oTime "> </span>
[解决办法]
<style type= "text/css ">
#oTime {
color: blue;
font-size: 12px;
}
</style>
<script language= "javascript ">
var _t;
var _h = 2;
var _m = 0;
var _s = 0;
if (document.cookie.indexOf( 'record= ') != -1) {
var index1 = document.cookie.indexOf( 'record= ') + 7;
var index2 = document.cookie.indexOf( '; ', index1);
index2 = index2 == -1 ? document.cookie.length : document.cookie.indexOf( '; ', index1);
var temp = document.cookie.substring(index1, index2);
_h = temp.substring(0, temp.indexOf( ': '));
_m = temp.substring(temp.indexOf( ': ') + 1, temp.indexOf( ': ', temp.indexOf( ': ') + 1));
_s = temp.substring(temp.indexOf( ': ', temp.indexOf( ': ') + 1)+1);
}
else {
document.cookie = 'record= '+_h + ': ' + _m + ': ' + _s;
}
var _v = formatTime(_h + ': ' + _m + ': ' + _s);
function doTime() {
_s --;
if (_s == -1) {
_m --;
_s = 59;
}
if (_m == -1) {
_h --;
_m = 59;
}
var _b = ((_h == 0) && (_m == 0) && (_s == 0));
if (_b) {
_v = 'Welcome To IECN.NET ';
clearTimeout(_t);
} else {
_v = formatTime(_h + ': ' + _m + ': ' + _s);
document.all[ 'oTime '].innerHTML = _v;
document.cookie = 'record= ' + _h + ': ' + _m + ': ' + _s;
_t = setTimeout( 'doTime() ', 1000);
}
}
function formatTime(_time) {
return _time.replace(/\b(\w)\b/g, '0$1 ');
}
onload = function() {
document.all[ 'oTime '].innerHTML = _v;
_t = setTimeout( 'doTime() ', 1000);
}
</script>
<span id= "oTime "> </span>