这篇文章主要介绍了javascript实现浏览器窗口传递参数,需要的朋友可以参考下
a.html
<html> <head> <title>主页面</title> <script language="javascript" type="text/javascript"> function OpenNew() { var im=new IDAndMethod(); im.ID=document.getElementById("txtID").value; window.showModalDialog("ddd.html",im,""); } function IDAndMethod() { this.ID="ddd"; this.Method=SetTxt; } function SetTxt(str) { document.getElementById("txtID").value=str; } </script> </head> <body> <form action="#"> <input type="text" value="XXX!在这里输入ID!" /><br /> <input type="button" value="打开新的窗口" /> </form> </body> </html>
b.html
<html> <head> <title>主页面</title> <script language="javascript" type="text/javascript"> var im; function Load() { im=window.dialogArguments; if(im.ID=="XXX!在这里输入ID") document.getElementById("txtID1").value="你杂不输入呢!"; else document.getElementById("txtID1").value=im.ID; } function Set() { im.Method(document.getElementById("txtID1").value); } </script> </head> <body> <form action="#"> <input type="text" value="ddd" /><br /> <input type="button" value="传递数据" /> </form> </body> </html>
您可能感兴趣的文章: