子窗體與父窗體傳值示例js代碼
更新時(shí)間:2013年08月01日 15:24:39 作者:
子窗體與父窗體之見互相傳值實(shí)現(xiàn)使用中很頻繁,本文以一個(gè)小示例拋磚引玉,希望大家可以舉一反三
復(fù)制代碼 代碼如下:
//返回值給父窗體
function returnParent(value) {//獲取子窗體返回值
var parent = window.dialogArguments; //獲取父頁面
//parent.location.reload(); //刷新父頁面
if (parent != null && parent != "undefined") {
window.returnValue = value; //返回值
window.close(); //關(guān)閉子頁面
}
//window.opener.document.getElementById("ActivityPic");//直接操作父窗體元素
//$(selector, window.parent.document);用于框架類頁面
//$(selector, window.opener.document);這個(gè)適合單獨(dú)打開的頁面
return;
}
//打開模式子窗體,獲取返回值進(jìn)行操作
function showModalOnly(me, url) { //彈出窗體 ,單選
var hidden = document.getElementById(me); //獲取隱藏的控件
if (hidden != null && hidden.value != null && hidden.value.length > 0) {
alert("此處為單選,請(qǐng)先刪除已有的選項(xiàng),再次嘗試選擇。");
return;
}
var reValue = window.showModalDialog(url, window, "dialogHeight:500px; dialogWidth:987px; status:off; scroll:auto");
if (reValue == null || reValue == "undefined" || reValue == "") {
return; //如果返回值為空,就返回
}
var index = reValue.split("^"); //分割符 ^ 的位置
if (index[0] == null || index[0] == "undefined" || index[0].length < 1) {
return;
}
var hid = index[0].split('&'); //為隱藏控件賦值
var view = index[1].split('&'); //顯示值
var content = ""; //需要添加到check中的內(nèi)容
if (hid != null && hid.length == 2) {
var i = 0;
if (hid[i] != "undefined" && hid[i] != "" && view[i + 1] != "undefined" && view[i + 1] != "") {
content += '<table id="' + hid[i]
+ '" class="deleteStyle"><tr><td><img src="../../../Images/deleteimge.png" title="點(diǎn)擊刪除" alt="刪除" onclick=" deleteTable('
+ "'" + hid[i] + "'," + "'" + me + "'" + ');" /></td><td>' + view[i + 1] + '</td></tr></table>';
hidden.value = hid[i]; //為隱藏控件賦值
var c = document.getElementById("check" + me);
c.innerHTML += content;
return;
}
}
alert("請(qǐng)只選擇一條數(shù)據(jù)。");
return;
}
function openUploadWindow(url, width, height,left,top) {
if(width==null) width=987;
if (height == null) height = 500;
if (left == null) left = 200;
if (top == null) top = 200;
//window.open(url, 'newwindow', 'height=' + height + ',width=' + width + ',top=200,left=200,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
window.showModalDialog(url, window, "dialogHeight:" + height + "px; dialogWidth:" + width + "px;status:off; scroll:auto;dialogLeft:"+left+"px;dialogTop:"+top+"px");
}
相關(guān)文章
js 獲取范圍內(nèi)的隨機(jī)數(shù)實(shí)例代碼
下面小編就為大家?guī)硪黄猨s 獲取范圍內(nèi)的隨機(jī)數(shù)實(shí)例代碼。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-08-08
javascript制作網(wǎng)頁圖片上實(shí)現(xiàn)下雨效果
這里給大家分享的是一則使用javascript實(shí)現(xiàn)在網(wǎng)頁圖片上下雨的特效,效果非常炫酷,推薦給小伙伴們。2015-02-02
JS+CSS實(shí)現(xiàn)可以凹陷顯示選中單元格的方法
這篇文章主要介紹了JS+CSS實(shí)現(xiàn)可以凹陷顯示選中單元格的方法,實(shí)例分析了javascript操作css的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03
JS DOM實(shí)現(xiàn)鼠標(biāo)滑動(dòng)圖片效果
這篇文章主要為大家詳細(xì)介紹了JS DOM實(shí)現(xiàn)鼠標(biāo)滑動(dòng)圖片效果,只要將鼠標(biāo)放上該商品的區(qū)域,原本折疊起來的商品便會(huì)自動(dòng)展開,感興趣的小伙伴們可以參考一下2016-03-03
原生js實(shí)現(xiàn)簡單的Ripple按鈕實(shí)例代碼
本篇文章主要介紹了原生js實(shí)現(xiàn)簡單的Ripple按鈕實(shí)例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-03-03
javascript實(shí)現(xiàn)獲取服務(wù)器時(shí)間
本文給大家總結(jié)了一下使用javascript來獲取服務(wù)器時(shí)間的幾種方法和思路,十分的簡單明了,有需要的小伙伴可以參考下2015-05-05
JS實(shí)現(xiàn)網(wǎng)頁游戲中滑塊響應(yīng)鼠標(biāo)點(diǎn)擊移動(dòng)效果
這篇文章主要介紹了JS實(shí)現(xiàn)網(wǎng)頁游戲中滑塊響應(yīng)鼠標(biāo)點(diǎn)擊移動(dòng)效果,涉及JavaScript針對(duì)頁面鼠標(biāo)事件、滾動(dòng)事件及元素屬性等相關(guān)操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10

