需求
在一個界面中打開另一個界面,通過JS獲取在另一個界面中用戶輸入的值。
示例:
Index.html
代碼如下:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gbk">
<title>主頁</title>
<script type="text/javascript">
function EntryPoint() {
var style = 'dialogHeight:600px;dialogWidth:800px;status:no;help:0;scrool:yes';
var a = window.showModalDialog('other.html', '', style);
if (a == undefined) {
a = window.returnValue;
}
// debugger;
if (a != null && a.length > 0) {
document.getElementById("name").value = a[0];
document.getElementById("age").value = a[1];
}
}
</script>
</head>
<body>
<input type="button" value="調(diào)用" onclick="EntryPoint()"/><br/>
<input type="text" name="name" id="name" /><br/>
<input type="text" name="age" id="age" />
</body>
</html>
另一個界面:
other.html
代碼如下:
<html>
<head>
<title>操作界面</title>
<meta http-equiv="content-type" content="text/html; charset=gbk">
<script type="text/javascript">
新聞熱點
疑難解答
圖片精選