function get_hs_page(cur_page, total_page) {
var result = "";
for(var i = 1; i <= total_page; i++) {
if(i == 2 && cur_page - 6 > 1) {
i = cur_page - 6;
}else if(i == cur_page + 6 && cur_page + 6 < total_page) {
i = total_page - 1;
}else{
if(i == cur_page){
result += "<li><a style='background-color:#e7e7e7;' href='/topic?page="+i+"&type=hs'>"+i+"</a></li>";
}else{
result += "<li><a href='/topic?page="+i+"&type=hs'>"+i+"</a></li>";
}
}
}
return result;
}
转载于:https://www.cnblogs.com/danson/p/4996681.html