window给父窗口传递数值window.open,windows.showModelessDialog
测试1.html
<html> <head> <title>爱问知识人网-awzsr.com 父窗口</title> <script language="javascript"> function look(){ //window.open("2.html"); //temp = window.showModelessDialog('2.html',window); var ret = window.showModalDialog("2.html",null,"dialogWidth:350px;dialogHeight:350px;help:no;status:no"); if (ret){ alert(ret); } // if (ret){ // alert('子窗口返回真!'); // }else{ // alert('子窗口返回假!'); // } //if(temp)alert(temp); } </script> </head> <body> <input type="button" onClick="look();" value="查看商品列表" /></br> <div ><span>你选择的商品是:</span><span id="result"></span></div> </body> </html> |
测试页面2.html
<html> <head> <title></title> </head> <body> <input type="checkbox" value="" name="test" value="1" /> <input type="checkbox" value="" name="test" value="2" /> <input type="checkbox" value="" name="test" value="3" /> <input type="button" value="提交" onClick="look();" /> </body> </html> <script language="javascript"> function look(){ //var test = document.getElementById("test").value; //window.opener.document.getElementById("result").innerHTML="test"; //window.dialogArguments.document. window.returnValue="1234" window.close(); } </script> |
说明:
示例代码可以用 window.open,和window.showModalDialog两种方法给父窗口传递数值,第二中方法火狐不支持,但IE都是可以正常运行的