· VReturnValue:对于showModalDialog(),它表示被打开的对话框窗口设置的returnValue属性值。对于showModelessDialog(),它表示新窗口对象。 · VFreeArgument:这个参数可用于传递某种类型的数据到打开的对话框,数据可以是一个数值、字符串、数组或者一个对象类型。在新窗口中引用这个数值时,可通过新创建window对象的dialogArguments 属性。 · SOrnaments:用这个参数指定新窗口的外观。可选择的窗口属性有很多种,当有多种控制需求时,将相关内容用一个字符串连接起来,其间用分号隔开。以下是可选择的属性种类: o dialogHeight: sHeight o dialogLeft: sXpos o dialogTop: sYpos o dialogWidth: sWidth o center: ( yes | no | 1 | 0 | on | off ) o dialogHide: ( yes | no | 1 | 0 | on | off ) o edge: ( sunken | raised ) o help: ( yes | no | 1 | 0 | on | off ) o resizable: ( yes | no | 1 | 0 | on | off ) o scroll: ( yes | no | 1 | 0 | on | off ) o status: ( yes | no | 1 | 0 | on | off )
二、控制对话框大小和位置
三、改变对话框外观
四、从Noname1.html页面传递数据到Noname2.html页面
传递对象类型数据
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>模态窗口和非模态窗口</TITLE> <script language="javascript"> var sColor="yyyy"; var sName="xmddl369"; function showModalWindow(){ window.showModalDialog('Noname2.html',window,'dialogWidth:400px;dialogHeight:400px'); } function showModellessWindow(){ window.showModelessDialog('Noname2.html',window,'dialogWidth:400px;dialogHeight:400px;edge:sunken'); } function update() { oColor.innerText = sColor; } document.write("sColor="+sColor+"<br>"); document.write("sName="+sName+"<br>"); </script> </HEAD> <BODY> <form> <input type="button" name="button" value="打开一个模态窗口" onclick="showModalWindow()"> <input type="button" name="button" value="打开一个非模态窗口" onclick="showModellessWindow()"> <BR> <P>输入你最喜欢的颜色: <SPAN ID="oColor" STYLE="color:red;font-size:24">Yellow</SPAN></P> </form> </BODY> </HTML> ------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <script language="javascript"> function getInfoAndUpdate() { var callerWindowObj = dialogArguments; //得到文档的引用 callerWindowObj.sColor = document.all("oEnterColor").value; callerWindowObj.update(); } function cancel() { var callerWindowObj = dialogArguments; callerWindowObj.sColor ="Yellow"; callerWindowObj.update(); } </script> </HEAD> <BODY> <form> 输入你最喜欢的颜色:<INPUT type="text" name="oEnterColor" ID="oEnterColor"><BR><BR> <INPUT VALUE="Apply" TYPE=button onclick="getInfoAndUpdate();"> <INPUT VALUE="Ok" TYPE=button onclick="getInfoAndUpdate();window.close();"> <INPUT VALUE="Cancel" TYPE=button onclick="cancel();window.close();"> </form> </BODY> </HTML>
传递数组引用类型数据
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>模态窗口和非模态窗口</TITLE> <script language="javascript"> var fruit=new Array(); fruit[0]="苹果"; fruit[1]="桔子"; fruit[2]="梨"; fruit[3]="香蕉"; function showModalWindow(){ window.showModalDialog('Noname2.html',fruit,'dialogWidth:400px;dialogHeight:400px'); } function showModellessWindow(){ window.showModelessDialog('Noname2.html',fruit,'dialogWidth:400px;dialogHeight:400px;edge:sunken'); } </script> </HEAD> <BODY> <form> <input type="button" name="button" value="打开一个模态窗口" onclick="showModalWindow()"> <input type="button" name="button" value="打开一个非模态窗口" onclick="showModellessWindow()"> <BR> </form> </BODY> </HTML> ------------------ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <SCRIPT LANGUAGE="JScript"> function deWrite(){ var myobject=document.getElementById("ifruit"); var myfruit=dialogArguments; for(count=0;count<myfruit.length;count++){ var oOption = document.createElement("OPTION"); oOption.text=myfruit[count]; oOption.value=/count; myobject.add(oOption); } } </SCRIPT> </HEAD> <BODY> <form> <input type="button" name="button" value="click me" onclick="deWrite()"> <br>增加水果: <SELECT ID="ifruit" NAME="ifruit"> </SELECT> </form> </BODY> </HTML>
传递值类型数据
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>模态窗口和非模态窗口</TITLE> <script language="javascript"> function showModalWindow(){ window.showModalDialog('Noname2.html',"xmddl",'dialogWidth:400px;dialogHeight:400px'); } function showModellessWindow(){ window.showModelessDialog('Noname2.html',"xmddl369",'dialogWidth:400px;dialogHeight:400px;edge:sunken'); } </script> </HEAD> <BODY> <form> <input type="button" name="button" value="打开一个模态窗口" onclick="showModalWindow()"> <input type="button" name="button" value="打开一个非模态窗口" onclick="showModellessWindow()"> <BR> </form> </BODY> </HTML> ------------------ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <SCRIPT LANGUAGE="JScript"> function deWrite(){ var names=dialogArguments;// document.write(names); } </SCRIPT> </HEAD> <BODY> <form> <input type="button" name="button" value="click me" onclick="deWrite()"> </form> </BODY> </HTML>
其中window.Open(url,,)的一点体会
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <script language="javascript"> function showOpenWindow(){ window.open('http://www.sohu.com','xmddl','height=600px,width=800px,toolbar=no,menubar=no,resizable=yes, scrollbars=yes, location=no, status=no'); } </script> </HEAD> <BODY> <form> <input type="button" name="button" value="click me" onclick="showOpenWindow()"> </form> </BODY> </HTML>