Jquery的blockUI使用

1.首先要準備好關於jquery的js文件
包括jquery-1.2.3.js和jquery.blockUI.js
2.在前臺JSP頁面中調用Jquery

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'JqueryShowBlock.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script language="JavaScript" type="text/javascript"
src="<%=path %>/jquery/jquery-1.2.3.js"></script>
<script type="text/javascript" src="<%=path %>/jquery/jquery.blockUI.js"></script>
<script language="JavaScript">
function showBlock(){
jQuery.blockUI({ message: "處理中,請稍候...", css: {color:'#fff',border:'3px solid #aaa',backgroundColor:'#CC3300'},overlayCSS: { opacity:'0.0' }});
setTimeout('hideBlock()',2000);//2000毫秒後調用hideBlock()
}
function hideBlock(){
jQuery.unblockUI();
}
</script>

</head>

<body>
This is my JSP page. <br>
ShowJqueryBlock Start:<input type="button" id="showBlock" value="ShowBlock" onclick="showBlock()"/><br/>
</body>
</html>

關於jquery文件的目錄結構如下:
---WebRoot
--------jquery
-----------jquery-1.2.3.js
-----------jquery.blockUI.js
3.頁面執行結果如下:

[img]http://dl.iteye.com/upload/attachment/478483/5068317d-5dea-3f3d-bb15-f2bc0b744647.png[/img]

當點擊"ShowBlock"按鈕時會調用jquery的jQuery.blockUI方法,"處理中,請稍後..."的jquery的block信息會顯示,並且將頁面鎖定;過2000毫秒後調用jQuery.unblockUI()將jquery的block信息取消。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章