// 设置当前窗口url中param的值
function set_param(param,value){
var query = location.search.substring(1);
var p = new RegExp("(^|&"+param+")=[^&]*");
if(p.test(query)){
query = query.replace(p,"$1="+value);
location.search = '?'+query;
}else{
if(query == ''){
location.search = '?'+param+'='+value;
}else{
location.search = '?'+query+'&'+param+'='+value;
}
}
}
在上一个翻页代码,其中用有到了上面两个函数
// 下一页
function page_next(current_page,page_total){
if(current_page < 1 || current_page >= page_total){
return false;
}
var next_page = parseInt(current_page) + 1;
set_param('page',next_page);
}
新闻热点
疑难解答