在网上随便找的一点资料,主要通过window.dialogArguments或window.returnValue
传入参数:
要想对话框传递参数,是通过vArguments来进行传递的。类型不限制,对于字符串类型,最大为4096个字符。也可以传递对象,例如: test1.htm
====================
<script>
var mxh1 = new Array("mxh","net_lover","孟子E章")
var mxh2 = window.open("about:blank","window_mxh")
// 向对话框传递数组
window.showModalDialog("test2.htm",mxh1)
// 向对话框传递window对象
window.showModalDialog("test3.htm",mxh2)
</script> test2.htm
====================
<script>
var a = window.dialogArguments
alert("您传递的参数为:" + a)
</script> test3.htm
====================
<script>
var a = window.dialogArguments
alert("您传递的参数为window对象,名称:" + a.name)
</script> 可以通过window.returnValue向打开对话框的窗口返回信息,当然也可以是对象。例如: test4.htm
===================
<script>
var a = window.showModalDialog("test5.htm")
for(i=0;i<a.length;i++) alert(a[i])
</script> test5.htm
===================
<script>
function sendTo()
{
var a=new Array("a","b")
window.returnValue = a
window.close()
}
</script>
<body>
<form>
<input value="返回" type=button onclick="sendTo()">
</form>
传入参数:
要想对话框传递参数,是通过vArguments来进行传递的。类型不限制,对于字符串类型,最大为4096个字符。也可以传递对象,例如: test1.htm
====================
<script>
var mxh1 = new Array("mxh","net_lover","孟子E章")
var mxh2 = window.open("about:blank","window_mxh")
// 向对话框传递数组
window.showModalDialog("test2.htm",mxh1)
// 向对话框传递window对象
window.showModalDialog("test3.htm",mxh2)
</script> test2.htm
====================
<script>
var a = window.dialogArguments
alert("您传递的参数为:" + a)
</script> test3.htm
====================
<script>
var a = window.dialogArguments
alert("您传递的参数为window对象,名称:" + a.name)
</script> 可以通过window.returnValue向打开对话框的窗口返回信息,当然也可以是对象。例如: test4.htm
===================
<script>
var a = window.showModalDialog("test5.htm")
for(i=0;i<a.length;i++) alert(a[i])
</script> test5.htm
===================
<script>
function sendTo()
{
var a=new Array("a","b")
window.returnValue = a
window.close()
}
</script>
<body>
<form>
<input value="返回" type=button onclick="sendTo()">
</form>
解决方案 »
- 为什么js事件函数默认传递的参数是event?
- iframe自刷新问题 方法在火狐报异常但能得到结果,在ie不执行
- 多个timer = window.setInterval(" ",)时,怎样终止定时刷新
- 表单取值
- 小问题 js
- 请问怎样可以用Javascript控制Iframe的活动条
- 求javascript生成html的方法
- 这段代码为什么在Netscape7.1下按Button,不触发事件(IE下有效)
- 二级的下拉菜单
- 如何使一个层div浮在框架(Frame,不是iFrame)的在最上层!!
- 关闭网页时弹出"是否设为首页"的对话框问题
- JavaScript二维数组怎么定义???恳请大家帮帮忙!!!(在线等)
test1.htm:
<script>
var result;//保存结果
window.show.showModalDialog("test2.htm",result)
</script>test2.htm:
<script>
window.dialogArguments = mytextbox.value;//其中 mytextbox 为你的文本框的名字
</script>
{}<input type="text" name="text1">
<input type="text" name="text2">
<input type="text" name="text3">
<input type="text" name="text4">
test2.htm<input type="hidden" name="a1" value="缅">
<input type="hidden" name="a2" value="甸">
<input type="hidden" name="a3" value="球">
<input type="hidden" name="a4" value="蟒">
<input type="button" name="提交" onclick="window.dialogArguments.test()">在showModalDialog窗口页面test2.htm中有四个值,单击"提交"按钮执行 test1.htm中的test(),使test1中的input得到test2中的值。如果在 test2.htm 中直接写下面的代码,可以让test1 取到 showModalDialog 的值,例如window.dialogArguments.document.all.text4.value = document.all.a4.value ;
但由于test1.htm 中的输入框中的名称不能确定,输入框的数量也不能确定,(根据不同需求可能只往test1传入一个或两个或三个参数)为了方便调用,所以想在test1 中做控制。请高手指教