极乐门资源网 Design By www.ioogu.com
科讯sql商业版中用到的ajax空间与分页函数,他们的js代码学习是非常不错的
//ajax 控件
function PageAjax(){
var xhrObj=null;
if(window.XMLHttpRequest)
{
xhrObj=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
try{
xhrObj=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e1)
{
try{
xhrObj=new ActiveXObject("MSXML2.XMLHTTP");
}
catch(e2){
try{
xhrObj=new ActiveXObject("MSXML3.XMLHTTP");
}
catch(e3){
alert("创建Ajax失败:"+e3)
}
}
}
}
else
{
alert("未能识别的浏览器");
}
return xhrObj;
}
function Page(curPage,labelid,classid,installdir,url,refreshtype,specialid)
{
this.labelid=labelid;
this.classid=classid;
this.url=url;
if (labelid.substring(0,5)=="{SQL_")
{
var slabelid=labelid.split('(')[0];
slabelid=slabelid.replace("{","");
this.c_obj="c_"+slabelid;
this.p_obj="p_"+slabelid;
}
else
{
this.c_obj="c_"+labelid;
this.p_obj="p_"+labelid;
}
this.installdir=installdir;
this.refreshtype=refreshtype;
this.specialid=specialid;
this.page=curPage;
loadData(1);
}
function loadData(p)
{ this.page=p;
var xhr=new PageAjax();
xhr.open("get",installdir+url+"?labelid="+escape(labelid)+"&classid="+classid+"&refreshtype="+refreshtype+"&specialid=" +specialid+"&curpage="+p,true);
xhr.onreadystatechange=function (){
if(xhr.readyState==1)
{
if (p==1)
eval('document.all.'+c_obj).innerHTML="<div align='center'><img src='"+installdir+"images/loading.gif'>正在连接服务器...</div>";
}
else if(xhr.readyState==2 || xhr.readyState==3)
{
if (p==1)
eval('document.all.'+c_obj).innerHTML="<div align='center'><img src='"+installdir+"images/loading.gif'>正在读取数据...</div>";
}
else if(xhr.readyState==4)
{
if (xhr.status==200)
{
var pagearr=xhr.responseText.split("{ks:page}")
var pageparamarr=pagearr[1].split("|");
count=pageparamarr[0];
perpagenum=pageparamarr[1];
pagecount=pageparamarr[2];
itemunit=pageparamarr[3];
itemname=pageparamarr[4];
pagestyle=pageparamarr[5];
getObject(c_obj).innerHTML=pagearr[0];
pagelist();
}
}
}
xhr.send(null);
}
function getObject(id)
{
if(document.getElementById)
{
return document.getElementById(id);
}
else if(document.all)
{
return document.all[id];
}
else if(document.layers)
{
return document.layers[id];
}
}
function pagelist()
{
var n=1;
var statushtml=null;
switch(parseInt(this.pagestyle))
{
case 1:
statushtml="共"+this.count+this.itemunit+" <a href=\"javascript:homePage(1);\" title=\"首页\">首页</a> <a href=\"javascript:previousPage()\" title=\"上一页\">上一页</a> <a href=\"javascript:nextPage()\" title=\"下一页\">下一页</a> <a href=\"javascript:lastPage();\" title=\"最后一页\">尾页</a> 页次:<font color=red>"+this.page+"</font>/"+this.pagecount+"页 "+this.perpagenum+this.itemunit+this.itemname+"/页";
break;
case 2:
statushtml="<a href='#'>"+this.pagecount+"页/"+this.count+this.itemunit+"</a> <a href=\"javascript:homePage(1);\" title=\"首页\"><font face=webdings>9</font></a> <a href=\"javascript:previousPage()\" title=\"上一页\"><font face=webdings>7</font></a> ";
var startpage=1;
if (this.page==10)
startpage=2;
else if(this.page>10)
startpage=eval((parseInt(this.page/10)-1)*10+parseInt((this.page)%10)+2);
for(var i=startpage;i<=this.pagecount;i++){
if (i==this.page)
statushtml+="<a href=\"#\"><font color=\"#ff0000\">"+i+"</font></a> "
else
statushtml+="<a href=\"javascript:turn("+i+")\">"+i+"</a> "
n=n+1;
if (n>10) break;
}
statushtml+="<a href=\"javascript:nextPage()\" title=\"下一页\"><font face=webdings>8</font></a> <a href=\"javascript:lastPage();\" title=\"最后一页\"><font face=webdings>:</font></a>";
statushtml="<span class='kspage'>"+statushtml+"</span>";
break;
case 4:
statushtml="共"+this.pagecount+"页/"+this.count+this.itemunit+this.itemname+" <a href=\"javascript:homePage(1);\" title=\"首页\"><font face=webdings>9</font></a> <a href=\"javascript:previousPage()\" title=\"上一页\"><font face=webdings>7</font></a> ";
for(var i=this.page;i<=this.pagecount;i++){
if (i==this.page)
statushtml+="<b><font color=\"#ff0000\">"+i+"</font></b> "
else
statushtml+="<a href=\"javascript:turn("+i+")\">["+i+"]</a> "
n=n+1;
if (n>10) break;
}
statushtml+="<a href=\"javascript:nextPage()\" title=\"下一页\"><font face=webdings>8</font></a> <a href=\"javascript:lastPage();\" title=\"最后一页\"><font face=webdings>:</font></a>";
break;
case 3:
statushtml="第<font color=#ff000>"+this.page+"</font>页 共"+this.pagecount+"页 <a href=\"javascript:homePage(1);\" title=\"首页\"><<</a> <a href=\"javascript:previousPage()\" title=\"上一页\"><</a> <a href=\"javascript:nextPage()\" title=\"下一页\"</a> <a href=\"javascript:lastPage();\" title=\"最后一页\"></a> "+this.perpagenum+this.itemunit+this.itemname+"/页";
break;
}
statushtml+=" 第<select name=\"goto\" onchange=\"turn(parseInt(this.value));\">";
for(var i=1;i<=this.pagecount;i++){
if (i==this.page)
statushtml+="<option value='"+i+"' selected>"+i+"</option>";
else
statushtml+="<option value='"+i+"'>"+i+"</option>";
}
statushtml+="</select>页";
getObject(this.p_obj).innerHTML=statushtml;
}
function homePage()
{
if(this.page==1)
alert("已经是首页了!")
else
loadData(1);
}
function lastPage()
{
if(this.page==this.pagecount)
alert("已经是最后一页了!")
else
loadData(this.pagecount);
}
function previousPage()
{
if (this.page>1)
loadData(this.page-1);
else
alert("已经是第一页了");
}
function nextPage()
{
if(this.page<this.pagecount)
loadData(this.page+1);
else
alert("已经到最后一页了");
}
function turn(i)
{
loadData(i);
}
//ajax 控件
function PageAjax(){
var xhrObj=null;
if(window.XMLHttpRequest)
{
xhrObj=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
try{
xhrObj=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e1)
{
try{
xhrObj=new ActiveXObject("MSXML2.XMLHTTP");
}
catch(e2){
try{
xhrObj=new ActiveXObject("MSXML3.XMLHTTP");
}
catch(e3){
alert("创建Ajax失败:"+e3)
}
}
}
}
else
{
alert("未能识别的浏览器");
}
return xhrObj;
}
function Page(curPage,labelid,classid,installdir,url,refreshtype,specialid)
{
this.labelid=labelid;
this.classid=classid;
this.url=url;
if (labelid.substring(0,5)=="{SQL_")
{
var slabelid=labelid.split('(')[0];
slabelid=slabelid.replace("{","");
this.c_obj="c_"+slabelid;
this.p_obj="p_"+slabelid;
}
else
{
this.c_obj="c_"+labelid;
this.p_obj="p_"+labelid;
}
this.installdir=installdir;
this.refreshtype=refreshtype;
this.specialid=specialid;
this.page=curPage;
loadData(1);
}
function loadData(p)
{ this.page=p;
var xhr=new PageAjax();
xhr.open("get",installdir+url+"?labelid="+escape(labelid)+"&classid="+classid+"&refreshtype="+refreshtype+"&specialid=" +specialid+"&curpage="+p,true);
xhr.onreadystatechange=function (){
if(xhr.readyState==1)
{
if (p==1)
eval('document.all.'+c_obj).innerHTML="<div align='center'><img src='"+installdir+"images/loading.gif'>正在连接服务器...</div>";
}
else if(xhr.readyState==2 || xhr.readyState==3)
{
if (p==1)
eval('document.all.'+c_obj).innerHTML="<div align='center'><img src='"+installdir+"images/loading.gif'>正在读取数据...</div>";
}
else if(xhr.readyState==4)
{
if (xhr.status==200)
{
var pagearr=xhr.responseText.split("{ks:page}")
var pageparamarr=pagearr[1].split("|");
count=pageparamarr[0];
perpagenum=pageparamarr[1];
pagecount=pageparamarr[2];
itemunit=pageparamarr[3];
itemname=pageparamarr[4];
pagestyle=pageparamarr[5];
getObject(c_obj).innerHTML=pagearr[0];
pagelist();
}
}
}
xhr.send(null);
}
function getObject(id)
{
if(document.getElementById)
{
return document.getElementById(id);
}
else if(document.all)
{
return document.all[id];
}
else if(document.layers)
{
return document.layers[id];
}
}
function pagelist()
{
var n=1;
var statushtml=null;
switch(parseInt(this.pagestyle))
{
case 1:
statushtml="共"+this.count+this.itemunit+" <a href=\"javascript:homePage(1);\" title=\"首页\">首页</a> <a href=\"javascript:previousPage()\" title=\"上一页\">上一页</a> <a href=\"javascript:nextPage()\" title=\"下一页\">下一页</a> <a href=\"javascript:lastPage();\" title=\"最后一页\">尾页</a> 页次:<font color=red>"+this.page+"</font>/"+this.pagecount+"页 "+this.perpagenum+this.itemunit+this.itemname+"/页";
break;
case 2:
statushtml="<a href='#'>"+this.pagecount+"页/"+this.count+this.itemunit+"</a> <a href=\"javascript:homePage(1);\" title=\"首页\"><font face=webdings>9</font></a> <a href=\"javascript:previousPage()\" title=\"上一页\"><font face=webdings>7</font></a> ";
var startpage=1;
if (this.page==10)
startpage=2;
else if(this.page>10)
startpage=eval((parseInt(this.page/10)-1)*10+parseInt((this.page)%10)+2);
for(var i=startpage;i<=this.pagecount;i++){
if (i==this.page)
statushtml+="<a href=\"#\"><font color=\"#ff0000\">"+i+"</font></a> "
else
statushtml+="<a href=\"javascript:turn("+i+")\">"+i+"</a> "
n=n+1;
if (n>10) break;
}
statushtml+="<a href=\"javascript:nextPage()\" title=\"下一页\"><font face=webdings>8</font></a> <a href=\"javascript:lastPage();\" title=\"最后一页\"><font face=webdings>:</font></a>";
statushtml="<span class='kspage'>"+statushtml+"</span>";
break;
case 4:
statushtml="共"+this.pagecount+"页/"+this.count+this.itemunit+this.itemname+" <a href=\"javascript:homePage(1);\" title=\"首页\"><font face=webdings>9</font></a> <a href=\"javascript:previousPage()\" title=\"上一页\"><font face=webdings>7</font></a> ";
for(var i=this.page;i<=this.pagecount;i++){
if (i==this.page)
statushtml+="<b><font color=\"#ff0000\">"+i+"</font></b> "
else
statushtml+="<a href=\"javascript:turn("+i+")\">["+i+"]</a> "
n=n+1;
if (n>10) break;
}
statushtml+="<a href=\"javascript:nextPage()\" title=\"下一页\"><font face=webdings>8</font></a> <a href=\"javascript:lastPage();\" title=\"最后一页\"><font face=webdings>:</font></a>";
break;
case 3:
statushtml="第<font color=#ff000>"+this.page+"</font>页 共"+this.pagecount+"页 <a href=\"javascript:homePage(1);\" title=\"首页\"><<</a> <a href=\"javascript:previousPage()\" title=\"上一页\"><</a> <a href=\"javascript:nextPage()\" title=\"下一页\"</a> <a href=\"javascript:lastPage();\" title=\"最后一页\"></a> "+this.perpagenum+this.itemunit+this.itemname+"/页";
break;
}
statushtml+=" 第<select name=\"goto\" onchange=\"turn(parseInt(this.value));\">";
for(var i=1;i<=this.pagecount;i++){
if (i==this.page)
statushtml+="<option value='"+i+"' selected>"+i+"</option>";
else
statushtml+="<option value='"+i+"'>"+i+"</option>";
}
statushtml+="</select>页";
getObject(this.p_obj).innerHTML=statushtml;
}
function homePage()
{
if(this.page==1)
alert("已经是首页了!")
else
loadData(1);
}
function lastPage()
{
if(this.page==this.pagecount)
alert("已经是最后一页了!")
else
loadData(this.pagecount);
}
function previousPage()
{
if (this.page>1)
loadData(this.page-1);
else
alert("已经是第一页了");
}
function nextPage()
{
if(this.page<this.pagecount)
loadData(this.page+1);
else
alert("已经到最后一页了");
}
function turn(i)
{
loadData(i);
}
极乐门资源网 Design By www.ioogu.com
极乐门资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
极乐门资源网 Design By www.ioogu.com
暂无科讯商业版中用到的ajax空间与分页函数的评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。
更新日志
2025年01月23日
2025年01月23日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]