jquery showModelDialog的使用方法示例詳解
前兩天接到這樣一個任務:在用戶上傳附件,需要校驗用戶上傳附件中身份證信息,如果存在錯誤信息需要將所有的錯誤信息展示出來。
這個需求我一開始考慮得就是使用jQuery Dialog。但是看到這個項目沒有使用而是使用showModelDialog,所以為了統(tǒng)一,也需要使用showModelDialog。
window.showModalDialog()方法用來創(chuàng)建一個顯示HTML內(nèi)容的模態(tài)對話框,由于是對話框,因此它并沒有一般用window.open()打開的窗口的所有屬性。
使用方法:
varreturnValue = window.showModalDialog(URL [, arguments] [, features])
參數(shù)說明:
URL:必選參數(shù):用來指定對話框要顯示的文檔的URL。
arguments:可選參數(shù)。用來向?qū)υ捒騻鬟f參數(shù)。傳遞的參數(shù)類型不限,包括數(shù)組等。對話框通過window.dialogArguments來取得傳遞進來的參數(shù)。
features可選參數(shù)。用來描述對話框的外觀等信息,可以使用以下的一個或幾個,用分號”;”隔開。
dialogHeight 對話框高度,不小于100px。
dialogWidth: 對話框?qū)挾取?nbsp;
dialogLeft: 距離桌面左的距離。
dialogTop: 離桌面上的距離。
center: {yes| no | 1 | 0 }:窗口是否居中,默認yes,但仍可以指定高度和寬度。 help: {yes | no | 1 | 0 }:是否顯示幫助按鈕,默認yes。 resizable: {yes | no | 1 | 0 } [ie5+]:是否可被改變大小。默認no。 status: {yes | no | 1 | 0 } [IE5+]:是否顯示狀態(tài)欄。默認為yes[ Modeless]或no[Modal]。 scroll:{ yes | no | 1 | 0 | on | off }:指明對話框是否顯示滾動條。默認為yes。
示例:
var rv = window.showModalDialog("<%=path%>/query/query_showErrorInfo.action","","dialogWidth=600px;dialogHeight="+height+"px;dialogLeft=400px;dialogTop=200px;center=no;resizable=no");
height:是根據(jù)展示的個數(shù)進行控制的。
url:為一個action,該action用戶獲取所有的錯誤人員信息。同時跳轉(zhuǎn)到errorInfo.jsp頁面
errorInfo.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>批量查詢身份錯誤人員名單</title>
<script type="text/javascript" src="/bjlc/js/jquery-1.4.4.min.js"></script>
<link href="/bjlc/css/queryErrorInfo.css" rel="stylesheet" type="text/css" />
<link href="/bjlc/css/index.css" rel="stylesheet" type="text/css" /> </head>
<base target="download">
<body>
<div class="errorMain">
<div class="errorBtn">
<input type="button" value="我要修改" class="button_08" onclick="wyxg();"/>
<input type="button" value="繼續(xù)查詢" class="button_08" onclick="jxcx();"/>
</div>
<div id="showErrorInfo">
<table class="errorTable" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" class="errorTitle">錯誤人員名單</td>
<s:form theme="simple" id="error_download" namespace="/query" method="post"></s:form>
</tr>
<tr>
<td width="20%" align="center">姓名</td>
<td width="30%" align="center">身份證</td>
<td width="50%" align="center">錯誤信息</td>
</tr>
<s:iterator value="#request.ecList">
<tr>
<td><s:property value="xm"/> </td>
<td><s:property value="sfz"/> </td>
<td><s:property value="message"/> </td>
</tr>
</s:iterator>
</table>
</div>
</div>
</body>
<SCRIPT type="text/javascript">
//設置高度
function setHeight(){
var _allH = $(".errorMain").height();
var _H1 = $("#showErrorInfo").height();
if(_allH>=536){
$("#showErrorInfo").css("height","500px")
}
}
window.onload = setHeight;
</SCRIPT>
</html>
樣式表:queryErrorInfo.css
html,body,.errorMain{
overflow:hidden;
height: 100%;
height: 100%;
}
#showErrorInfo{
width: 100%;
OVERFLOW-Y: auto;
OVERFLOW-X:hidden;
}
.errorTable{
width: 90%;
margin: 10px 5%;
font-size: 12px;
border: 1px solid #8DC8FF;
}
.errorTable td{
height: 40px;
border-right: 1px solid #8DC8FF;
border-bottom:1px solid #8DC8FF;
text-align: center;
}
.errorTable td:last-child{
border-right: 0px;
}
td[id="btn"]{
border-bottom: 0px;
}
.errorTitle{
font-weight: bold;
font-size: 14px;
background-color: #C6E3FF;
color: #176ED2;
text-align: center;
}
.errorBtn{
width: 100%;
height: 20px;
text-align: center;
bottom: 0px;
position:absolute;
}
結(jié)果如下:
相關文章
jQuery實現(xiàn) RadioButton做必選校驗功能
這篇文章主要介紹了jQuery實現(xiàn) RadioButton做必選校驗功能的相關資料,需要的朋友可以參考下2017-06-06打造基于jQuery的高性能TreeView(asp.net)
項目中經(jīng)常會遇到樹形數(shù)據(jù)的展現(xiàn),包括導航,選擇等功能,所以樹控件在大多項目中都是必須的。那一個實用的樹應該具備什么功能呢?2011-02-02