window.returnValue使用方法示例介绍
2014-07-03 08:52
986 查看
window.showModalDialog是弹出模式窗口的方法
returnValue是javascript中html的window对象的属性,目的是返回窗口值,当用window.showModalDialog函数打开一个IE的模式窗口(模式窗口知道吧,就是打开后不能操作父窗口,只能等模式窗口关闭时才能操作)时,用于返回窗口的值,下面举个例子:
1、parent.html
//father.html <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <TITLE></TITLE> <script language="javascript"> function showmodal(){ var ret = window.showModalDialog("child.htm",null,"dialogWidth:350px;dialogHeight:350px;help:no;status:no"); if (ret){alert('子窗口返回真!'); }else{ alert('子窗口返回假!'); } } </script> </HEAD> <BODY> <INPUT id=button1 type=button value=Button name=button1 onclick="showmodal();"> </BODY> </HTML>
2、child.html
//child.html <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <TITLE></TITLE> <script language="javascript"> function trans(tag){ if (tag==0){ window.returnValue=false; } else{ window.returnValue =true; } window.close(); } </script> </HEAD> <BODY> <INPUT id=button1 type=button value="返回真" name=button1 onclick="trans(1)"> <INPUT id=button2 type=button value="返回假" name=button2 onclick="trans(0)"> </BODY> </HTML>
总结:
这样一来可以实现从模式窗口向父窗口传递值的作用,这个returnValue除了可以是布尔值,整型值等以外还可以是个js数组,用来传递大量数据。
具体showModalDialog等的用法,可以参考msdn。
相关文章推荐
- window.returnValue使用方法示例介绍
- window.returnValue和 window.showModalDialog()和window.close()的使用方法
- window.returnValue使用方法
- window.returnValue使用方法
- window.returnValue使用方法(转)
- window.returnValue使用方法
- window.returnValue使用方法
- window.returnValue使用方法
- window.returnValue使用方法(转)
- window.returnValue使用方法
- BackgroundWorker控件的使用方法介绍及示例程序
- JS教程:window.location使用方法的区别介绍
- window.scrollTo()方法使用示例
- window.resizeBy()方法使用示例
- 使用POST方式弹出窗口的两种方法示例介绍
- ExtJS4中的requires使用方法示例介绍
- window.event.keycode使用方法介绍
- 关于js页面之间跨域传值问题 opener parent等等 使用window.returnValue
- window.resizeBy()方法使用示例