如何在web上实现等待提示。

类别:Java 点击:0 评论:0 推荐:

由于某个jsp页面要实现较长等待时间功能的时候,对于用户,此时IE中是空白页。

如何让处理过程中出现等待的提示,我把自己的解决思路奉献给大家。
创建一个等待页面,
包含两个层layer1,layer2.layer1出现等待提示,layer2 包含iframe,利用iframe调用你那个长时间的jsp。开始时layer2隐藏,layer1显示。

等jsp处理结束后,利用

<script language="javascript">
  if(parent.layer3.style.display!="block")
  {
   parent.layer1.style.display="none";
   parent.layer2.style.display="block";
  }

把提示的哪个层隐藏,自己的层显示。


下面为我的等待页代码:

<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
机动车统计
</title>
</head>
<style type="text/css">
<!--
body {
 margin-left: 0px;
 margin-top: 0px;
 margin-right: 0px;
 margin-bottom: 0px;
}
-->
</style>
<body bgcolor="#C0C0C0">
<%
  String sBeginDate=request.getParameter("startDate");
  String sEndDate=request.getParameter("endDate");
  String sBeginGLBM=request.getParameter("startGLBM");
  String IsChk=(String)request.getParameter("IsChk");
  String sPreStatisticYear=(String)request.getParameter("preStatisticYear");
  String sStatisticYear=(String)request.getParameter("StatisticYear");
  String sEndGLBM=request.getParameter("endGLBM");
  String strUrl=request.getParameter("url"); 
  String strTj = strUrl + "?startDate=" + sBeginDate+"&endDate="+ sEndDate + "&IsChk="+ IsChk +
    "&preStatisticYear="+ sPreStatisticYear+"&StatisticYear="+sStatisticYear+"&startGLBM="+sBeginGLBM+"&endGLBM="+sEndGLBM; 
  %>
<div style="position: absolute; width: 100%; height: 100%; z-index: 1" id="layer1">
<p align="center"> </p>
<p align="center"> </p>
<table align="center"><tr><td>
<div style="font-size:8pt;padding:2px;border:solid black 1px">
<span id="progress1">&nbsp; &nbsp;</span>
<span id="progress2">&nbsp; &nbsp;</span>
<span id="progress3">&nbsp; &nbsp;</span>
<span id="progress4">&nbsp; &nbsp;</span>
<span id="progress5">&nbsp; &nbsp;</span>
<span id="progress6">&nbsp; &nbsp;</span>
<span id="progress7">&nbsp; &nbsp;</span>
<span id="progress8">&nbsp; &nbsp;</span>
<span id="progress9">&nbsp; &nbsp;</span>
</div>
</td></tr></table>
<script language="javascript">
var progressEnd = 9;  // set to number of progress <span>'s.
var progressColor = 'blue'; // set to progress bar color
var progressInterval = 1000; // set to time between updates (milli-seconds)

var progressAt = progressEnd;
var progressTimer;
function progress_clear() {
 for (var i = 1; i <= progressEnd; i++) document.getElementById('progress'+i).style.backgroundColor = 'transparent';
 progressAt = 0;
}
function progress_update() {
 progressAt++;
 if (progressAt > progressEnd) progress_clear();
 else document.getElementById('progress'+progressAt).style.backgroundColor = progressColor;
 progressTimer = setTimeout('progress_update()',progressInterval);
}
function progress_stop() {
 clearTimeout(progressTimer);
 progress_clear();
}
progress_update();  // start progress bar
</script>

<p align="center"><b><font size="4" face="黑体">处理数据中,请稍后。。。。。。。</font></b></p>
</div>
<div style="position: absolute; width: 100%; height: 100%; z-index: 1" id="layer2">
 <iframe name="I2" marginwidth="1" marginheight="1" height="100%" width="100%"  src="<%=strTj%> ">
 浏览器不支持嵌入式框架,或被配置为不显示嵌入式框架。</iframe></div>
<div style="position: absolute; width: 100%; height: 100%; z-index: 1" id="layer3">
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"><b><font size="4" face="黑体" color="blue">处 理 数 据 出 错!</font></b></p>
<p align="center"><textarea rows="15" name="S1" cols="53"></textarea></p>
<p align="center"><input type="button" value=" 关 闭 " name="B3" onclick="window.close()"></p>
</div>

<script language="javascript">
  layer2.style.display="none";
  layer3.style.display="none";
</script>
</body>
</html>

本文地址:http://com.8s8s.com/it/it11378.htm