cookie保存分页参数

时间:2022-05-22 18:04:35
<script src="../Public/js/jquery.cookie.js"></script>
<script type="text/javascript">
$(function () { if($.cookie('ACTIVITY_AJAX_PAGESIZE')>0){
$("#commonselect option").remove();
var arr = new Array(5,10,12,15,20,30,50,100);
for(var i=0;i<arr.length;i++){
//alert(arr[i]);
if(arr[i] == $.cookie('ACTIVITY_AJAX_PAGESIZE')){
$("#commonselect").append("<option selected='selected' value="+arr[i]+'>'+arr[i]+'</option>');
}else{
$("#commonselect").append('<option value='+arr[i]+'>'+arr[i]+'</option>'); } }
//用完后删除cookie,即页面加载完毕后
$.cookie('ACTIVITY_AJAX_PAGESIZE', '', { expires: -1 }); // 删除 cookie
} $("#commonselect").live('change',function(){
$.cookie('ACTIVITY_AJAX_PAGESIZE',$(this).val(),{expires:365,path:'/'});
window.location.reload();//刷新当前页面.
});
});
</script>