<!DOCTYPE html>
<html>
<head>
<title>parent.html</title>
<script type="text/javascript">
function openChild() {
var obj = new Object();
var pVal = showModalDialog("child.html", obj ,"dialogWidth=200px;dialogHeight=100px");
alert(pVal);
alert(obj.name);
}
</script>
</head>
<body>
<button id="parent" οnclick="openChild()">获得数据</button>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>child.html</title>
<script type="text/javascript">
var obj = window.dialogArguments;
function submit() {
obj.name = "xxxxx";
window.returnValue = document.getElementById("pText").value;
window.close();
}
</script>
</head>
<body>
<input type="text" id="pText" />
<br>
<input type="button" value="确定" onClick="submit()" />
<input type="button" value="取消" onClick="window.close();" />
</body>
</html>
showModalDialog
最新推荐文章于 2014-01-02 16:29:10 发布