浏览器刷新后Javascript问题维护历史记录?

时间:2013-01-08 09:04:38

标签: javascript

var _history = new Array();
var _index=-1;
function updateHistory(shapeparam)
{
    _index = _index + 1;    
    _history.splice(_index,_history.length);
    _history.push(shapeparam);
}

从上面的代码我可以维护历史而不刷新它工作正常。 我希望即使刷新后也可以使用这些值, 请帮助我是否可以使用javascript cookies。

1 个答案:

答案 0 :(得分:0)

var _history = getCookie("history");
_history=_history?_history.split(","):[];
var _index=-1;
function updateHistory(shapeparam)
{
    _index = _index + 1;    
    _history.splice(_index,_history.length);
    _history.push(shapeparam);
    setCookie("history",_history.join(","));
}