1、首先是JSP文件 index.jsp

点击(此处)折叠或打开

  1. <%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  3. <html>
  4.   <head>
  5.     <link href="global.css" rel="stylesheet" type="text/css" />
  6.     <script type="text/javascript" src="jquery-1.4.2.js"></script>
  7.   </head>
  8.   
  9.   <script type="text/javascript">
  10.       //显示加载效果
  11.     function showPopDiv(){
  12.         $("#loading").css("display","block");
  13.         $("#popDiv").css("display","block");
  14.     }
  15.     //取消加载效果
  16.     function hiddenPopDiv(){
  17.         $("#loading").css("display","none");
  18.         $("#popDiv").css("display","none");
  19.     }
  20.     </script>
  21.   <body>
  22.     <input type="button" value="显示加载" onclick="showPopDiv();"/>
  23.     <div id="popDiv"></div>
  24.     <div id="loading"></div>
  25.     <input type="button" value="取消加载" onclick="hiddenPopDiv();"/>
  26.   </body>
  27. </html>

2、css文件 global.css

点击(此处)折叠或打开

  1. #loading{
  2.     position:fixed;_position:absolute;
  3.     display: none;
  4.     top:50%;left:50%;
  5.     width:124px;height:124px;
  6.     overflow:hidden;
  7.     background:url(loaderc.gif) no-repeat;z-index:7;
  8.     margin:-62px 0 0 -62px;
  9.     }
  10.       
  11. #popDiv{
  12.     margin-top:50px;
  13.     display: none;
  14.     position: absolute;
  15.     top: 0%;
  16.     left: 0%;
  17.     width: 100%; height: 100%;
  18.     background-color: black;
  19.     z-index:2; -moz-opacity: 0.7;
  20.     opacity:.70;
  21.     filter: alpha(opacity=5);
  22. }
3、加载效果图片 loaderc.gif

    【页面样式】JS与CSS实现页面加载遮罩效果-LMLPHP
4、在index.jsp中引入 jquery-1.4.2.js
    
08-29 20:15