================父窗口代碼======== <HEAD> <HTML> <HEAD> <TITLE>test2.htm</TITLE> <SCRIPT> var sUserName=""; // 彈出窗口 function fnCallDialog() { showModalDialog("test3.html", window, "dialogWidth:300px;dialogHeight:300px"); } // 根據子窗口的值,更新父窗口的頁面內容 function fnUpdate() { oName.innerText = sUserName; } </SCRIPT> </HEAD> <BODY> <P>Hello World <input type="TEXT" readonly ID="oName" value="JACK"></input></P> <INPUT TYPE="button" VALUE="Show Dialog" onclick="fnCallDialog()"> </BODY> </HTML> =============子窗口代碼============= <HTML> <HEAD> <TITLE>test3.htm</TITLE> <SCRIPT> function fnGetInfo() { // dialogArguments是接口參數,表示父窗口對象,不能變! var sData = dialogArguments; // 把本頁面輸入的值賦給父窗口的屬性 sData.sUserName = oEnterName.value; // 調用父窗口函數 sData.fnUpdate(); } </SCRIPT> </HEAD> <BODY> Enter your Name <INPUT ID=oEnterName><BR><BR> <INPUT VALUE="OK!!!" TYPE=button onclick="fnGetInfo();window.close();"> </BODY> </HTML> ===========第二個問題的代碼====== <HEAD> <HTML> <HEAD> <TITLE>test2.htm</TITLE> <SCRIPT> function getOptionValue(sObj) { mytext.value = sObj.value; } </SCRIPT> </HEAD> <BODY> <SELECT NAME="Cats" SIZE="1" onchange="getOptionValue(this)"> <OPTION VALUE="1">Hello <OPTION VALUE="2">World <OPTION VALUE="3">Jack </SELECT> <input type="text" id="mytext" value="1"/> </BODY> </HTML>