前兩天接到這樣一個任務:在用戶上傳附件,需要校驗用戶上傳附件中身份證信息,如果存在錯誤信息需要將所有的錯誤信息展示出來。
這個需求我一開始考慮得就是使用jQuery Dialog。但是看到這個項目沒有使用而是使用showModelDialog,所以為了統一,也需要使用showModelDialog。
window.showModalDialog()方法用來創建一個顯示HTML內容的模態對話框,由于是對話框,因此它并沒有一般用window.open()打開的窗口的所有屬性。
使用方法:
varreturnValue = window.showModalDialog(URL [, arguments] [, features])
參數說明:
URL:必選參數:用來指定對話框要顯示的文檔的URL。
arguments:可選參數。用來向對話框傳遞參數。傳遞的參數類型不限,包括數組等。對話框通過window.dialogArguments來取得傳遞進來的參數。
features可選參數。用來描述對話框的外觀等信息,可以使用以下的一個或幾個,用分號”;”隔開。
dialogHeight 對話框高度,不小于100px。
dialogWidth: 對話框寬度。
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+]:是否顯示狀態欄。默認為yes[ Modeless]或no[Modal]。 scroll:{ yes | no | 1 | 0 | on | off }:指明對話框是否顯示滾動條。默認為yes。
示例:
height:是根據展示的個數進行控制的。
url:為一個action,該action用戶獲取所有的錯誤人員信息。同時跳轉到errorInfo.jsp頁面
errorInfo.jsp
#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;
}
結果如下:
新聞熱點
疑難解答