2.我们可以利用模态对话框的dialogArguments属性来实现跨页面的数据传递,
通过如下方式可获得模态对话框的dialogArguments属性:
var Variables = window.dialogArguments
利用该属性可获得模态对话框的传入参数,可以是String, numeric, object, or array value that specifies arguments.尤其是对象或数组型的参数,对于在页面之间传递数据非常有用。举例如下:
传入页面:
<HTML> <HEAD> <SCRIPT> function AddNew(meetingID)
{
var obj=new Object();
obj.name="qiubinchao";
obj.tel="12345678";
var strUrl="../MeetingManage/NewMeeting.aspx?id="+meetingID;
window.showModalDialog(strUrl,obj,"dialogHeight:700px;dialogWidth=900px;dialogTop=10px;dialogLeft:50px;");
window.location="../MeetingManage/MeetingPublishedList.aspx";
}
</SCRIPT> </HEAD> <BODY> <BUTTON onclick="AddNew();" >Launch The Window</BUTTON> </BODY> </HTML> 接收页面:
<HTML> <HEAD> <SCRIPT> var oMyObject = window.dialogArguments; var name= oMyObject.name; var tel= oMyObject.tel; </SCRIPT> <title>Untitled</title> </head> <BODY STYLE="font-family: arial; font-size: 14pt; color: Snow; background-color: RosyBrown;"> Name: <SPAN STYLE="color:00ff7f"> <SCRIPT> document.write(name); </SCRIPT> </SPAN> <BR> Tel: <SPAN STYLE="color:00ff7f"> <SCRIPT> document.write(tel); </SCRIPT> </SPAN> </BODY> </HTML>