子窗體與父窗體之見互相傳值實現使用中很頻繁
本文以一個小示例拋磚引玉
希望大家可以舉一反三
復制代碼 代碼如下:
//返回值給父窗體
function returnParent(value) {//獲取子窗體返回值
var parent = windowdialogArguments; //獲取父頁面
//parentlocationreload(); //刷新父頁面
if (parent != null && parent != "undefined") {
windowreturnValue = value; //返回值
windowclose(); //關閉子頁面
}
//windowopenerdocumentgetElementById("ActivityPic");//直接操作父窗體元素
//$(selector windowparentdocument);用於框架類頁面
//$(selector windowopenerdocument);這個適合單獨打開的頁面
return;
}
//打開模式子窗體獲取返回值進行操作
function showModalOnly(me url) { //彈出窗體 單選
var hidden = documentgetElementById(me); //獲取隱藏的控件
if (hidden != null && hiddenvalue != null && hiddenvaluelength > ) {
alert("此處為單選請先刪除已有的選項再次嘗試選擇");
return;
}
var reValue = windowshowModalDialog(url window "dialogHeight:px; dialogWidth:px; status:off; scroll:auto");
if (reValue == null || reValue == "undefined" || reValue == "") {
return; //如果返回值為空就返回
}
var index = reValuesplit("^"); //分割符 ^ 的位置
if (index[] == null || index[] == "undefined" || index[]length < ) {
return;
}
var hid = index[]split(&); //為隱藏控件賦值
var view = index[]split(&); //顯示值
var content = ""; //需要添加到check中的內容
if (hid != null && hidlength == ) {
var i = ;
if (hid[i] != "undefined" && hid[i] != "" && view[i + ] != "undefined" && view[i + ] != "") {
content += <table id=" + hid[i]
+ " class="deleteStyle"><tr><td><img src="///Images/deleteimgepng" title="點擊刪除" alt="刪除" onclick=" deleteTable(
+ "" + hid[i] + "" + "" + me + "" + );" /></td><td> + view[i + ] + </td></tr></table>;
hiddenvalue = hid[i]; //為隱藏控件賦值
var c = documentgetElementById("check" + me);
cinnerHTML += content;
return;
}
}
alert("請只選擇一條數據");
return;
}
function openUploadWindow(url width heightlefttop) {
if(width==null) width=;
if (height == null) height = ;
if (left == null) left = ;
if (top == null) top = ;
//windowopen(url newwindow height= + height + width= + width + top=left=toolbar=nomenubar=noscrollbars=no resizable=nolocation=no status=no);
windowshowModalDialog(url window "dialogHeight:" + height + "px; dialogWidth:" + width + "px;status:off; scroll:auto;dialogLeft:"+left+"px;dialogTop:"+top+"px");
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20014.html