转载自:新浪 作者:于士博的BLOG 链接:http://blog.sina.com.cn/s/blog_4f925fc30100gssw.html
//父页面:
<input type=text name="desc" id="desc" value="大家好" />
</form>
<script>
var url = "/pub/doc/prints.jsp"; //子页面的URL
var popscript = "dialogWidth:1024px;dialogHeight:768px;center:yes;status:no;scrollbars:no";
var prints = window.showModalDialog(url, window, popscript);
function pmShow(){
alert("shihuan!");
}
alert(arg);
}
</script>
//子页面:
<script>
var argsDoc = window.dialogArguments.document;
alert(argsDoc.getElementById('desc').value);
dialogArguments.pmShow(); //调用父页面的JavaScript方法
dialogArguments.pmShow("haha"); //调用父页面的JavaScript方法,并传参
//parent.window.dialogArguments.pmShow();
//window.dialogArguments.parent.pmShow();
</script>
------------------------------------------------------------------------------------------------------
//父页面:
<form name=mainFrm action="" method="post">
<input type=text name="desc" id="desc" value="大家好" />
</form>
<script>
var url = "/pub/doc/prints.jsp"; //子页面的URL
var popscript = "dialogWidth:1024px;dialogHeight:768px;center:yes;status:no;scrollbars:no";
var prints = window.showModalDialog(url, {"myid":1, "myname":"shihuan"}, popscript);
</script>
//子页面:
<script>
var argsDoc = window.dialogArguments;
alert(argsDoc["myid"]);
alert(argsDoc["myname"]);
</script>