a.html
<html> <head> <title>Main Page</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 id="txtID" type="text" value="XXX! Enter ID here!" /><br /> <input type="button" value="Open New window" onclick="OpenNew()" /> </form> </body> </html>b.html
<html> <head> <title>Main page</title> <script language="javascript" type="text/javascript"> var im; function Load() { im=window.dialogArguments; if(im.ID=="XXX! Enter ID here") document.getElementById("txtID1").value="Would you enter it in any way!"; else document.getElementById("txtID1").value=im.ID; } function Set() { im.Method(document.getElementById("txtID1").value); } </script> </head> <body onload="Load()"> <form action="#"> <input id="txtID1" type="text" value="ddd" /><br /> <input type="button" value="pass data" onclick="Set()" /> </form> </body> </html>