javascript

位置:IT落伍者 >> javascript >> 浏览文章

子窗体与父窗体传值示例js代码


发布日期:2019年05月07日
 
子窗体与父窗体传值示例js代码
子窗体与父窗体之见互相传值实现使用中很频繁本文以一个小示例抛砖引玉希望大家可以举一反三复制代码 代码如下:


//返回值给父窗体
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");  
}

               

上一篇:利用JS延迟加载百度分享代码,提高网页速度

下一篇:javascript 得到文件后缀名的思路及实现