首页 > 代码库 > 模态窗口

模态窗口

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
//模态窗口
function btnOpen_Click(w_sp1, h_sp1){
var url = "2.html";
var iTop2 = (window.screen.availHeight - 20 - h_sp1) / 2;
var iLeft2 = (window.screen.availWidth - 10 - w_sp1) / 2;
var params = ‘menubar:no;dialogHeight=‘ + h_sp1 + ‘px;dialogWidth=‘ + w_sp1 + ‘px;dialogLeft=‘ + iLeft2 + ‘px;dialogTop=‘ + iTop2 + ‘px;resizable=yes;scrollbars=0;resizeable=0;center=yes;location:no;status:no‘
var obj=window.showModalDialog(url, window, params);
document.getElementById("userId").value=http://www.mamicode.com/obj[0];
document.getElementById("userAccount").value=http://www.mamicode.com/obj[1];
document.getElementById("username").value=http://www.mamicode.com/obj[2];
document.getElementById("userpwd").value=http://www.mamicode.com/obj[3];
}
</script>
</head>

<body>

<b>1</b> <input id="userId" type="text" name="userId" />
<b>5</b> <input id="userAccount" type="text" name="userAccount" onclick="btnOpen_Click(600,450);" />
<b></b> <input id="username" type="text" name="userId" />
<b></b> <input id="userpwd" type="text" name="userId" />
</body>
</html>

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function test(obj){
var td1 = obj.firstElementChild.firstChild.innerHTML;//1
var td2=obj.lastElementChild.firstChild.innerHTML;//5
var td3=obj.firstElementChild.nextElementSibling.firstElementChild.innerHTML;
var td4=obj.firstElementChild.nextElementSibling.nextElementSibling.firstElementChild.innerHTML;
var array=new Array();
array.push(td1);
array.push(td2);
array.push(td3);
array.push(td4);
window.returnValue=http://www.mamicode.com/array;
window.close();
}
</script>
</head>

<body>
<table border="1" id="table">
<tr>
<td><input name="" id="" value="http://www.mamicode.com/序号" /></td>
<td><input name="" id="" value="http://www.mamicode.com/数量" /></td>
<td><input name="" id="" value="http://www.mamicode.com/序号" /></td>
<td><input name="" id="" value="http://www.mamicode.com/数量" /></td>
</tr>
<tr ondblclick="test(this)" id="1">
<td><div>1</div></td>
<td><div>2</div></td>
<td><div>4</div></td>
<td><div>5</div></td>
</tr>
<tr ondblclick="test(this)" id="2">
<td><div>11</div></td>
<td><div>12</div></td>
<td><div>13</div></td>
<td><div>14</div></td>
</tr>
<tr ondblclick="test(this)" id="3">
<td><div>15</div></td>
<td><div>16</div></td>
<td><div>17</div></td>
<td><div>18</div></td>
</tr>
</table>
</body>
</html>

模态窗口