<html>
<head>
<script>
function dialog()
&leftsign;
var obj = new Object();
obj.name="shengfang";
str =window.showModalDialog("s.html",obj,"dialogWidth=200px;dialogHeight=100px");
alert("返回值为:" +str);
&rightsign;
</script>
</head>
<body>
<input name="" type="button" value="对话框" onClick="dialog()">
</body>
</html>
~~
<html>
<head>
<script>
function exit()
&leftsign;
var obj = window.dialogArguments
alert("您传递的参数为:" + obj.name)
window.returnValue = "http://www.yippeesoft.com";
window.close();
&rightsign;
</script>
</head>
<body>
<input name="" type="button" value="关闭窗口" onClick="exit()">
</body>
</html>
~
js模式对话框
<script>
var obj = new Object();
obj.name="51js";
window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
</script>
modal.htm
<script>
var obj = window.dialogArguments
alert("您传递的参数为:" + obj.name)
</script>
——————————-
2. 可以通过window.returnValue向打开对话框的窗口返回信息,当然也可以是对象。例如:
——————————
parent.htm
<script>
str =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");
alert(str);
</script>
modal.htm
<script>
window.returnValue="http://www.yippeesoft.com";
</script>
与openDialog传值时使用window.opener进行传值不同,
showModaldialog传值时应使用window.dialogArguments。
如:
//parent页面使用showModalDialog弹出对话框:
function showWindow(page)&leftsign;
window.showModalDialog(page,parent, "dialogHeight:180px;dialogWidth:380px;scrollbars:0;status:0;help:0;edge:sunken");
&rightsign;
//dialog页面则用下面的方法传值到parent:
opener = window.dialogArguments;
opener.document.testForm.***.value=…;//为parent页面的testForm的***属性传值
主窗口 main.html
<html>
<head>
<script language="javascript">
function abc()
&leftsign;
window.showModalDialog("newwindow.html",window,"dialogWidth:500px;dialogHeight:420px;help:0;status:0;resizable:0;scroll:0;center:1;");
&rightsign;
</script>
</head>
<body>
<img onclick=abc()>
<INPUT type="text" name="me">
</body>
</html>
对话框 newwindow.html
<html>
<head>
<script language="javascript">
var oParent;
function addvalue()
&leftsign;
oParent = window.dialogArguments;
alert(document.all["a"].value);
oParent.document.all["me"].value=document.all["a"].value;
window.close();
&rightsign;
</script>
</head>
<body>
<INPUT type="text" name="a" value="hello~">
<INPUT style="WIDTH: 80px" onclick="addvalue();" type="button" value="给父窗体赋值">
</body>
</html>
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cjamie/archive/2006/07/28/992036.aspx
历史博文
- 20090812 KIS2010 WIN2003 - 2009
- 20090813 Wordpress cms BBtheme 修改 - 2009
- 20090812 xml rpc comodo - 2009
- 20090807 Godaddy gegehost - 2009
- 20090807 双飞燕 G7630 电池 - 2009
- 20090807 c# WebBrowser NewWindow2 - 2009
- 20090807 c# Parent Process - 2009
- 20090803 長沙 益阳 印象 - 2009
- 20090803 益阳 丧俗 - 2009
- 20090803 母系 亲戚 外婆 - 2009