网上找的方法,原理和原先的上页下页跳转方式差不多,也是构造连接的方式
displaytag的配置文件修改三个属性如下:
paging.banner.full=<span class="pagelinks"><input name="tz" id="tz" size="3" type="text" value="{5}"/>/{6}页 <button onClick="displaytagURL()" >跳转</button>[<a href="{1}">首页</a>/<a href="{2}">上页</a>]{0}[<a href="{3}">下页</a>/<a href="{4}">尾页</a>]<input id="hd" name="hd" type="hidden" value="{1}"/><input id="totalPageNum" name="totalPageNum" type="hidden" value="{6}"/></span>
paging.banner.first=<span class="pagelinks"><input name="tz" id="tz" size="3" type="text" value="{5}"/>/{6}页 <button onClick="displaytagURL()" >跳转</button>[首页/上页] {0}[<a href="{3}">下页</a>/<a href="{4}">尾页</a>]<input id="hd" name="hd" type="hidden" value="{1}"/><input id="totalPageNum" name="totalPageNum" type="hidden" value="{6}"/></span>
paging.banner.last=<span class="pagelinks"><input name="tz" id="tz" size="3" type="text" value="{5}"/>/{6}页 <button onClick="displaytagURL()" >跳转</button>[<a href="{1}">首页</a>/<a href="{2}">上页</a>]{0} [下页/尾页]<input id="hd" name="hd" type="hidden" value="{1}"/><input id="totalPageNum" name="totalPageNum" type="hidden" value="{6}"/></span>
页面导入如下js:
function displaytagURL()
{
var arrayOf_table_Tag = document.getElementsByTagName('table');
for (var i=0; i<arrayOf_table_Tag.length; i++)
{
if(arrayOf_table_Tag[i].id == 'list') //displayTag table的id {
var charArray = "x-"+arrayOf_table_Tag[i].id;
var checkSum = 17;
for(var j = 0; j < charArray.length; j++)
{
checkSum = 3 * checkSum + charArray.charCodeAt(j);
}
checkSum &=8388607; //对form的名字的转换,这里可以在displaytag源码中看到
var parameterIdentifier = "d-" + checkSum + "-p=";
var arrayOf_a_Tag = document.getElementsByTagName('a');
for (var k=0; k<arrayOf_a_Tag.length; k++){
if(arrayOf_a_Tag[k].title.indexOf('转到第')==0)
{
var url = arrayOf_a_Tag[k].href;
var splitUrl = url.split("&");
for(var l=0;l<splitUrl.length;l++)
{
if(splitUrl[l].indexOf(parameterIdentifier)!=-1)
{
if(l==0)
{splitUrl[l]="?"+parameterIdentifier+document.getElementById('tz').value;}
else
{splitUrl[l]=parameterIdentifier+document.getElementById('tz').value;}
}
}
var realURL ='';
for(m=0;m<splitUrl.length;m++)
{
if(m!=splitUrl.length-1)
{realURL+=splitUrl[m]+'&';}
else
{realURL+=splitUrl[m];}
}
window.location=realURL;
break;
return;
}
}
}
}
}
displaytag的配置文件修改三个属性如下:
paging.banner.full=<span class="pagelinks"><input name="tz" id="tz" size="3" type="text" value="{5}"/>/{6}页 <button onClick="displaytagURL()" >跳转</button>[<a href="{1}">首页</a>/<a href="{2}">上页</a>]{0}[<a href="{3}">下页</a>/<a href="{4}">尾页</a>]<input id="hd" name="hd" type="hidden" value="{1}"/><input id="totalPageNum" name="totalPageNum" type="hidden" value="{6}"/></span>
paging.banner.first=<span class="pagelinks"><input name="tz" id="tz" size="3" type="text" value="{5}"/>/{6}页 <button onClick="displaytagURL()" >跳转</button>[首页/上页] {0}[<a href="{3}">下页</a>/<a href="{4}">尾页</a>]<input id="hd" name="hd" type="hidden" value="{1}"/><input id="totalPageNum" name="totalPageNum" type="hidden" value="{6}"/></span>
paging.banner.last=<span class="pagelinks"><input name="tz" id="tz" size="3" type="text" value="{5}"/>/{6}页 <button onClick="displaytagURL()" >跳转</button>[<a href="{1}">首页</a>/<a href="{2}">上页</a>]{0} [下页/尾页]<input id="hd" name="hd" type="hidden" value="{1}"/><input id="totalPageNum" name="totalPageNum" type="hidden" value="{6}"/></span>
页面导入如下js:
function displaytagURL()
{
var arrayOf_table_Tag = document.getElementsByTagName('table');
for (var i=0; i<arrayOf_table_Tag.length; i++)
{
if(arrayOf_table_Tag[i].id == 'list') //displayTag table的id {
var charArray = "x-"+arrayOf_table_Tag[i].id;
var checkSum = 17;
for(var j = 0; j < charArray.length; j++)
{
checkSum = 3 * checkSum + charArray.charCodeAt(j);
}
checkSum &=8388607; //对form的名字的转换,这里可以在displaytag源码中看到
var parameterIdentifier = "d-" + checkSum + "-p=";
var arrayOf_a_Tag = document.getElementsByTagName('a');
for (var k=0; k<arrayOf_a_Tag.length; k++){
if(arrayOf_a_Tag[k].title.indexOf('转到第')==0)
{
var url = arrayOf_a_Tag[k].href;
var splitUrl = url.split("&");
for(var l=0;l<splitUrl.length;l++)
{
if(splitUrl[l].indexOf(parameterIdentifier)!=-1)
{
if(l==0)
{splitUrl[l]="?"+parameterIdentifier+document.getElementById('tz').value;}
else
{splitUrl[l]=parameterIdentifier+document.getElementById('tz').value;}
}
}
var realURL ='';
for(m=0;m<splitUrl.length;m++)
{
if(m!=splitUrl.length-1)
{realURL+=splitUrl[m]+'&';}
else
{realURL+=splitUrl[m];}
}
window.location=realURL;
break;
return;
}
}
}
}
}