我有这个cookie jQuery.cookie("previousUrl", window.location.href, {path:"/"});
来存储上一页的网址。如何将此cookie用作window.location,以便当用户单击“后退按钮”时,它会将它们带到cookie中设置的页面URL?
干杯,
麦克
答案 0 :(得分:0)
首先获取cookie值
var cookieVal = $.cookie('previousUrl');
然后做
window.location.href = cookieVal;
答案 1 :(得分:0)
在jQuery
试试这个:
$(window).unload( function ()
{
// read cookies value and if its set then window.location.href = cookie value
}
在javascript
:
window.onbeforeunload = function () {
// read cookies value and if its set then window.location.href = cookie value
}