用frameset啊,作个top.htm就行了啊
解决方案 »
- JSP怎么向js传递参数啊,修改js里定义的boolean类型的值
- js 远程读取并解析xml效率问题,请教大家。
- javascript中出现乱码
- js页面传值
- 模态窗口showModelessDialog,子页面可否刷新???
- javascript取得焦点和失去焦点
- 请问:如何让一个打开的页面刷新一次,设置时间循环刷新的办法不用考虑,我需要能够主动控制,谢谢!
- ie5和ie6的问题,在线等待,分不够还可以在给
- 各位大神,求教JS写进JPG、PNG里可以运行吗?
- jquery-file-upload 选择多个文件上传只发一次请求
- 如何隐藏窗体,JS变量如何传给PHP变量(在一个页面内)。
- JavaScript迷惑问题之七:如何将.js文件中的大量的注释语句迅速除掉?
window.showModelessDialog('yourPage.htm',window,'dialogWidth:520px;dialogHeight:380px;help=no;status=no;resizable=no;scroll:no')
或者参考http://www.csdn.net/expert/topic/724/724606.xml?temp=.3066065
然后要考虑的就是emu说得对齐,代码估计会比较复杂。
能告诉我具体用分页的方法吗??----------------------------------------------------------------比如说,我现在从服务器查出来×××行数据(超过千行最好另想办法或做写优化)第一步,先放一个二维数组里面。可以用jsp来生成:ar=[[a,b,c],[d,e,f],[g,h,i]......] ,没问题吧?或者用xmlhttp从服务器端请求一个串过来再split(注意行和列用不同的分隔符)第二步:默认每页显示15行(根据你的页面怎么设置,我是允许用户自己选几行的),默认显示第一页,也就是说,var linesPerPage = 15 ; var currentPage=1;第三步:先准备好要显示数据的table,表头、各列的标题放到thead里面,表脚放到tfoot里面(这些在设计网页的时候就该做好了),把tbody清空(用deleteRow(),每次翻页前都要清空一次)。
while (tbody1.childern.length>0) tbody.deleteRow();第四步:根据指定的currentPage和linesPerpage从数组里找出来当前这一页要显示的数据,循环生成行插入到表格中(insertRow ,insertCell,不过我不喜欢用insertCell 而喜欢用cloneNode() ):第五步:显示当前的页码和上一页、下一页的按钮。用户选了新的页码或改变了每页的行数时,回第三步。你自己先做做试试看吧。自己多动手,提高才快。要实在做不出来,我的例子过两天再贴出来。
我看你几天没反应,以为你解决了呢。
急的话多过来提提帖子,大家才会注意到嘛。
要是你自己没试过的话,给你代码你也很难看懂啊。我可不是故意吊你胃口。
好了,贴代码。
注意:
排序部分为了提高速度,做了映射的,读代码时要注意。
在IE6.2600上通过的,在其他版本的IE上可能不能打印/预览<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body style="font-size:14">
<div id=div1 style="display:none"></div>
<CENTER>
<form onsubmit="event.returnValue=false;showPage()">
<span style="cursor:hand" onclick="document.all('PageNo').value--;showPage()"><<上一页</span>
<input id="PageNo" onChange="showPage();" size=4 value=1></input>
<span style="cursor:hand" onclick="document.all('PageNo').value++;showPage()">下一页>></span>
<span id="tips"> </span>
每页
<select onchange="linesPerPage=parseInt(this.value);document.all('PageNo').focus();document.all('PageNo').value=1;showPage()">
<option value=10>10</option>
<option value=15 selected >15</option>
<option value=20>20</option>
<option value=30>30</option>
<option value=50>50</option>
</select>个记录
<button onclick="doPrint()">打印</button>
<input type="checkbox" onClick="window.filters.style.display= (this.checked) ? '' : 'none' ;doFilter()">筛选</input>
</form>
</center>
<center id="filters" style="display:none">
<select id="colToFilter"></select>
<select id="limit" style="width:60">
<option value="include">包含</option>
<option value="uninclude">不包含</option>
<option value="equals">等于</option>
<option value="moreThan">大于</option>
<option value="lessThan">小于</option>
<option value="moreOrEquals">大于等于</option>
<option value="lessOrEquals">小于等于</option>
<option value="unequal">不等于</option>
</select>
<input id="filter" size=7 disabled />
<input type="checkbox" onClick="filter[0].disabled=!(this.checked)"/>
<select id="colToFilter">
</select>
<select id="limit" style="width:60">
<option value="include">包含</option>
<option value="uninclude">不包含</option>
<option value="equals">等于</option>
<option value="moreThan">大于</option>
<option value="lessThan">小于</option>
<option value="moreOrEquals">大于等于</option>
<option value="lessOrEquals">小于等于</option>
<option value="unequal">不等于</option>
</select>
<input id="filter" size=7 disabled />
<input type="checkbox" onClick="filter[1].disabled=!(this.checked)"/>
<select id="colToFilter">
</select>
<select id="limit" style="width:60">
<option value="include">包含</option>
<option value="uninclude">不包含</option>
<option value="equals">等于</option>
<option value="moreThan">大于</option>
<option value="lessThan">小于</option>
<option value="moreOrEquals">大于等于</option>
<option value="lessOrEquals">小于等于</option>
<option value="unequal">不等于</option>
</select>
<input id="filter" size=7 disabled />
<input type="checkbox" onClick="filter[2].disabled=!(this.checked)"/>
<button onclick="doFilter()">筛选</button>
</CENTER>
<div id="div2">
<TABLE>
<TR>
<th onclick="sort(0)" style="cursor:hand" tag="String">AA</th>
<th onclick="sort(1)" style="cursor:hand" tag="String">BB</th>
<th onclick="sort(2)" style="cursor:hand" tag="Number">CC</th>
<th onclick="sort(3)" style="cursor:hand" tag="Number">DD</th>
<th onclick="sort(4)" style="cursor:hand" tag="Number">EE</th>
<th onclick="sort(5)" style="cursor:hand" tag="Number">FF</th>
<th onclick="sort(6)" style="cursor:hand">GG</th>
<th onclick="sort(7)" style="cursor:hand">HH</th>
<th onclick="sort(8)" style="cursor:hand">II</th>
<th onclick="sort(9)" style="cursor:hand">JJ</th>
<th onclick="sort(10)" style="cursor:hand">KK</th>
<th onclick="sort(11)" style="cursor:hand">LL</th>
<th onclick="sort(12)" style="cursor:hand">MM</th>
<th onclick="sort(13)" style="cursor:hand">NN</th>
<th onclick="sort(14)" style="cursor:hand">OO</th>
<th onclick="sort(15)" style="cursor:hand">PP</th>
<th onclick="sort(16)" style="cursor:hand">QQ</th>
<th onclick="sort(17)" style="cursor:hand">RR</th>
<th onclick="sort(18)" style="cursor:hand">SS</th>
<th onclick="sort(19)" style="cursor:hand">TT</th>
<th onclick="sort(20)" style="cursor:hand">UU</th>
<th onclick="sort(21)" style="cursor:hand">VV</th>
<th onclick="sort(22)" style="cursor:hand">WW</th>
<th onclick="sort(23)" style="cursor:hand">XX</th>
<th onclick="sort(24)" style="cursor:hand">YY</th>
<th onclick="sort(25)" style="cursor:hand">ZZ</th>
<th onclick="sort(26)" style="cursor:hand">AAA</th>
<th onclick="sort(27)" style="cursor:hand">BBB</th>
<th onclick="sort(28)" style="cursor:hand">CCC</th>
<th onclick="sort(29)" style="cursor:hand">DDD</th>
</TR>
</TABLE>
</div>
<SCRIPT LANGUAGE="JavaScript">
<!--var lines=500 ; //这里控制数据两,先做500行试试速度。
var linesPerPage = 15;
var st ="";
var sortIndex = -1; //排序的列
var str = div2.firstChild.firstChild.innerHTML; //获得表头原始信息
var cols =div2.firstChild.firstChild.firstChild.children.length;//表头的列数
var tags = new Array(cols); //字段属性
for (var i=0;i<cols;i++)
tags[i] = div2.firstChild.firstChild.firstChild.children[i].tag;
var names = new Array(cols); //字段名
for (var i=0;i<cols;i++)
names[i] = div2.firstChild.firstChild.firstChild.children[i].innerText;
for (var i=0;i<colToFilter.length;i++) //准备筛选器
for (var j=0;j<cols;j++)
{
var elm = new Option();
elm.innerText = names[j];
elm.value = j;
colToFilter[i].appendChild(elm);
}var summary = new Array(cols); //各字段的汇总
summary[0] = "汇总";var ar = new Array(); //筛选后待分页、排序的数据
var ar0 = new Array(); //筛选前的源数据
var arIndex = 0;
div2.innerText="正在生成数据,请稍候......"setTimeout("for (var i=0; i<lines;i++) { var tmpst = \"<tr>\"; for (var j=0;j<30 ;j++) tmpst +=\"<td>\"+parseInt(Math.random()*1000)+\"</td>\"; tmpst +=\"</tr>\"; st +=tmpst;};div2.innerHTML = \"正在处理数据,请稍候 ......\";div2.innerHTML +=\"<table>\"+st.substring(0,3000)+\"</table>\";setTimeout(\"xml2array(st);doFilter();\",0);",0)
function doFilter() //筛选数据
{
var str = "true "
if (filters.style.display != "none")
for (var i = 0 ; i< filter.length ; i++)
if (!filter[i].disabled)
if (limit[i].value=="equals")
str += "&& (ar0[i]["+colToFilter[i].value+"].innerText == filter["+i+"].value)";
else if (limit[i].value=="moreThan")
str += "&& (parseFloat(ar0[i]["+colToFilter[i].value+"].innerText) > parseFloat(filter["+i+"].value))";
else if (limit[i].value=="lessThan")
str += "&& (parseFloat(ar0[i]["+colToFilter[i].value+"].innerText) < parseFloat(filter["+i+"].value))";
else if (limit[i].value=="moreOrEquals")
str += "&& (parseFloat(ar0[i]["+colToFilter[i].value+"].innerText) >= parseFloat(filter["+i+"].value))";
else if (limit[i].value=="lessOrEquals")
str += "&& (parseFloat(ar0[i]["+colToFilter[i].value+"].innerText) <= parseFloat(filter["+i+"].value))";
else if (limit[i].value=="unequal")
str += "&& (parseFloat(ar0[i]["+colToFilter[i].value+"].innerText) != parseFloat(filter["+i+"].value))";
else if (limit[i].value=="uninclude")
str += "&& (ar0[i]["+colToFilter[i].value+"].innerText.indexOf(filter["+i+"].value) == -1)";
else
str += "&& (ar0[i]["+colToFilter[i].value+"].innerText.indexOf(filter["+i+"].value)>-1)";
ar= new Array();
for (var i=0;i<ar0.length;i++)
if ( eval(str))
ar[ar.length] = ar0[i];
// 处理汇总
for (var i=1;i<cols;i++)
{
if (tags[i] == "Number")
{
var k = 0;
for (j=0;j<ar.length;j++)
k += parseFloat(ar[j][i].innerText)
summary[i]=k;
}
else
summary[i]=""; }
sortIndex = -1
showPage();
}
function showPage()
{ lines = ar.length;
document.all("PageNo").blur();
if (document.all("PageNo").value<1)
document.all("PageNo").value=1
if (document.all("PageNo").value > (lines+linesPerPage-1)/linesPerPage)
document.all("PageNo").value = parseInt((lines+linesPerPage-1)/linesPerPage)
tips.innerText = document.all("PageNo").value+"/"+parseInt((lines+linesPerPage-1)/linesPerPage)+" 记录数:"+lines
var tmpPage=parseInt(document.all("PageNo").value);
var EndBy = tmpPage*linesPerPage;
if (lines<EndBy) EndBy=lines
ar2 = new Array()
if (tmpPage >0)
{
for (var i=(tmpPage-1)*linesPerPage;i<EndBy;i++)
{
ar2[ar2.length]=ar[i]
}
div2.innerHTML = array2table(ar2,(EndBy == lines));
}
else alert ("没有匹配的记录");
}
function sort(i)
{
document.all("PageNo").value=1;
var sortType = tags[i];
if (i == sortIndex)
{
ar.reverse();
showPage()
}
else
{
div2.innerText = "正在重新排序,请稍候......"
sortIndex = i;
if (sortType == "Number")
setTimeout("ar = sortAr(ar,true);showPage();");
else
setTimeout("ar = sortAr(ar,false);showPage();");
}
}
function sortObj (val,lineIndex)
{
this.lineIndex = lineIndex;
this.value = val;
this.toString = tostr;
}
function tostr()
{
return this.value;
}
function sortAr(ar,isInt)
{
var tmpar1 = new Array(ar.length)
var tmpar2 = new Array(ar.length)
if (isInt)
for (var i=0;i<ar.length;i++)
{
var str = "0000000000"+ar[i][sortIndex].innerText;
tmpar1[i] = new sortObj(str.substring(str.length-10),i);
}
else
for (var i=0;i<ar.length;i++)
tmpar1[i] = new sortObj(ar[i][sortIndex].innerText,i);
tmpar1.sort();
for (var i=0;i<ar.length;i++)
tmpar2[i] = ar[tmpar1[i].lineIndex];
return tmpar2; }