JSP如何做"正在加载数据,请稍等..."这样的提示页面 loding。。。

http://fantasy.iteye.com/blog/67320

-----------------------

用ajax:ajax发个异步请求的时候 调用一个div显示 数据正在加载中 ……”,
接收到请求的时候 关闭div就可以了

-------------------------------------

在要加载jsp页面的html代码 <body> 下添加如下:
<div   id= "sending "   style= "filter:alpha(opacity=80);   position:absolute;   top:310px;   left:135px;   z-index:10;   visibility:hidden;   width:   617px;   height:   81px; ">
<TABLE   WIDTH=80%   BORDER=0   CELLSPACING=0   CELLPADDING=0> 
        <TR>
               <td   width=30%> </td>
               <td   bgcolor=#104A7B> 
                       <table  WIDTH=100%   height=80   BORDER=0   CELLSPACING=2   CELLPADDING=0>
                               <tr>
                                       <td   bgcolor=#eeeeee   align=center> 正在处理数据,   请稍候... </td>
                               </tr>
                      </table>
               </td>
               <td   width=30%> </td>
        </tr>
</table>
</div>

然后触发提交按钮事件的时候:sending.style.visibility= "visible "
OK!

 如果需要等待的时间比较长,你可以把页面上的按钮在提交之后将按钮设置为buttonName.disabled=true,这样可以防止用户等不耐烦而再按。

 

------------------------------------------------------------------------

 

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
a{ color:#000; font-size:12px;text-decoration:none}
a:hover{ color:#900; text-decoration:underline}

#massage_box{ position:absolute; left:expression((body.clientWidth-40)/2); top:expression((body.clientHeight-40)/2); width:40px; height:40px;filter:dropshadow(color=#666666,offx=3,offy=3,positive=2); z-index:2; visibility:hidden}
#mask{ position:absolute; top:0; left:0; bottom:0;width:expression(body.scrollWidth); height:100%; background:#666; filter:ALPHA(opacity=60); z-index:1; visibility:hidden}
.massage{border:#036 solid; border-width:1 1 3 1; width:95%; height:95%; background:#fff; color:#036; font-size:12px; line-height:150%}
.header{background:#036; height:10%; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; padding:3 5 0 5; color:#fff}
</style>
<script>
 function createXMLHttpRequest() 
  { 
  if(window.ActiveXObject) 
  { 
  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
  } 
  else 
  { 
  if(window.XMLHttpRequest) 
  { 
  xmlHttp = new XMLHttpRequest(); 
  } 
  } 
  } 

  function LoadPageWait() 
  { 
  createXMLHttpRequest(); 
  // var url = "http://extjs.com/deploy/ext-1.1/docs/";
  var url = "http://www.163.com/"; 
  // var url = "test.html"; 
  xmlHttp.open("GET", url, true); 
  xmlHttp.onreadystatechange = goCallback; 
  xmlHttp.send(null); 
  } 

  function goCallback() 
  {  
   
  if(xmlHttp.readyState == 1) 
  { 
  // document.getElementById("Label1").innerHTML = "数据读取中."; 
  mask.style.visibility='visible';
  massage_box.style.visibility='visible';
  } 
  if(xmlHttp.readyState == 2) 
  { 
  // document.getElementById("Label1").innerHTML = "数据初始化."; 
  mask.style.visibility='visible';
  massage_box.style.visibility='visible';
  } 
  if(xmlHttp.readyState == 3) 
  { 
  // document.getElementById("Label1").innerHTML = "数据载入中."; 
  mask.style.visibility='visible';
  massage_box.style.visibility='visible';
  } 
  if(xmlHttp.readyState == 4) 
  { 
  // document.getElementById("Label1").innerHTML = "页面加载中."; 
  mask.style.visibility='visible';
  massage_box.style.visibility='visible';
  setTimeout("WriteData()", 1); 
  } 
   
  } 
  function WriteData() 
  { 
  window.location.replace("http://www.163.com/"); 
  //window.location.replace("1.html"); 
  return false; 
  }
</script>
</head>

<body>

  <label>
  <input type="submit" name="test" id="test" value="提交" onclick="LoadPageWait()"/>
  </label>

  
<p>
<div id="massage_box"><div class="massage">

<img src="loading.gif" width="32" height="32" />
</div></div>
<div id="mask"></div>

</body>
</html>


你可能感兴趣的:(JSP如何做"正在加载数据,请稍等..."这样的提示页面 loding。。。)