简体   繁体   English

HTML页面加载时间过长,页面无响应

[英]HTML page taking too much time to load and page is becoming irresponsive

My web page is taking too much time to load. 我的网页加载时间太长。 reason is that page have a HTML table which has around 3000 columns and every column has a text box within it. 原因是该页面具有一个HTML表,该表包含约3000列,并且每列中都有一个文本框。 Is there a way so that I can reduce the loading time or suggest if there is any other alternative. 有没有一种方法可以减少加载时间或建议是否还有其他选择。

thanks in advance 提前致谢

EDIT - Ok let me tell you the exact senerio, my table needs to show the date wise data and the Date (like 14-Dec-2012) will be the column header itself. 编辑-好的,让我告诉您确切的senerio,我的表需要显示按日期排列的数据,而Date(例如2012年12月14日)将是列标题本身。 the latest date will be the first column, then the past dates will comes across, some thing like (14-Dec-2012|13-Dec-2012|12-Dec-2012.....) every day when system date changes a new column would be added as the first column. 最新日期将是第一列,然后是过去日期,例如系统日期更改的每一天(2012年12月14日| 2012年12月13日| 2012年12月12日.....)新列将添加为第一列。 There are around 200 rows. 大约有200行。 Its an JSP page and in a for loop I am creating the table header first, then in second for loop creating the table cells containing the values in textbox (so that user can edit them anytime). 它是一个JSP页面,在for循环中,我首先创建表头,然后在第二个for循环中,创建包含文本框中值的表单元(以便用户可以随时对其进行编辑)。

code sample - Header - 代码示例-标头-

<%
    Date today = new Date();
    String col = "";
    today = RDUtils.addDays(today, 1);
for(int i=0;i<=columnCount;i++){
    today = RDUtils.addDays(today, -1);
    col = RDUtils.getStringDateCol(today);
%>
<th class="TableHeader"><div><%=col%></div></th>
<%} %>

Table cells - 表格单元格-

for(int j=0;j<=columnCount;j++){%>
    <input maxlength="5" onblur="fillZero(this);" onFocus='clearField(this);' onkeypress="if (checkEnter())return false;" onkeyup='if (checkEnter()) move("<%=i %>");' size="5" type="text" name="txtEntry<%=de.getId()%>" value="<%=val%>" id="<%=de.getId()%>"/></div> </td>

JS functions - JS函数-

function checkEnter(e){
    characterCode = e.keyCode;
    return characterCode == 13;
}
function fillZero(obj){
if(obj.value==''){
    obj.value = 0;
}
 }
 function clearField(obj){
var perfix = obj.name.substring(8, obj.name.length);
var chkObj = document.getElementById('deCheck'+perfix);
if(!chkObj.checked)chkObj.checked=true;
if(obj.value==0){
    obj.value = '';
}
 }

It is better to use pagination using Datatables . 最好通过Datatables使用分页。

And use the AJAX method. 并使用AJAX方法。

$(document).ready(function() {
    $('#example').dataTable( {
        "bProcessing": true,
        "sAjaxSource": '../ajax/sources/arrays.txt'
    } );
} );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM