参考网址:
1、http://www.daimajiayuan.com/download/201304/yulan/artDialog4.1.7/
2、http://aui.github.io/artDialog/test/iframe/index.html
window 对象
浏览器会在其打开一个 HTML 文档时创建一个对应的 window 对象。但是,如果一个文档定义了一个或多个框架(即,包含一个或多个 frame 或 iframe 标签),浏览器就会为原始文档创建一个 window 对象,再为每个框架创建额外的 window 对象。这些额外的对象是原始窗口的 子窗口,可能被原始窗口中发生的事件所影响。例如,关闭原始窗口将导致关闭全部子窗口。如果想要创建新窗口(以及对应的 window 对象),可以使用像 open, showModalDialog 和 showModelessDialog 这样的方法。
contentWindow
contentWindow属性是指指定的frame或者iframe所在的window对象
在IE中iframe或者frame的contentWindow属性可以省略,但在Firefox中如果要对iframe对象进行编辑则必须指定contentWindow属性。
在子页面调用父页面的setVerifyDetail方法,同时把变量SelecLine传过去:
function retAttention() {
var win = art.dialog.open.origin;
win.document.getElementById("exit").contentWindow.setVerifyDetail(SelectLine);
art.dialog.close();
}
其它一些可以参考的代码:
<script>
if (art.dialog.data('test')) {
document.getElementById('aInput').value = art.dialog.data('test');// 获取由主页面传递过来的数据
};
// 传递给B页面
document.getElementById('aButton').onclick = function () {
var aValue = document.getElementById('aInput').value;
art.dialog.data('aValue', aValue);// 存储数据
var path = art.dialog.data('homeDemoPath') || './';//
art.dialog.open(path + 'iframeB.html?fd', {
id: 'AAA',
close: function () {
var bValue = art.dialog.data('bValue');// 读取B页面的数据
if (bValue !== undefined) document.getElementById('aInput').value = bValue;
}
}, false);
};
// 关闭并返回数据到主页面
document.getElementById('exit').onclick = function () {
var origin = artDialog.open.origin;
var aValue = document.getElementById('aInput').value;
var input = origin.document.getElementById('demoInput04-3');
input.value = aValue;
input.select();
art.dialog.close();
};
// 刷新主页面
document.getElementById('reload').onclick = function () {
art.dialog.data('iframeTools', '我知道你刷新了页面~哈哈'); // plugin.iframe.html可以收到
var win = art.dialog.open.origin;//来源页面
// 如果父页面重载或者关闭其子对话框全部会关闭
win.location.reload();
return false;
};
</script>
/**
* 警告
* @param {String}消息内容
*/
artDialog.alert = function (content, callback) {
return artDialog({
id: 'Alert',
icon: 'warning',
fixed: true,
// lock: true,
width:250,
height:50,
content: content,
ok: true,
close: callback
});
};
/**
* 确认
* @param {String}消息内容
* @param {Function}确定按钮回调函数
* @param {Function}取消按钮回调函数
*/
artDialog.confirm = function (content, yes, no) {
return artDialog({
id: 'Confirm',
icon: 'question',
fixed: true,
// lock: true,
opacity: .1,
width:250,
height:50,
content: content,
ok: function (here) {
return yes.call(this, here);
},
cancel: function (here) {
return no && no.call(this, here);
}
});
};
/**
* 提问
* @param {String}提问内容
* @param {Function}回调函数. 接收参数:输入值
* @param {String}默认值
*/
artDialog.prompt = function (content, yes, value) {
value = value || '';
var input;
return artDialog({
id: 'Prompt',
icon: 'question',
fixed: true,
// lock: true,
width:250,
height:50,
opacity: .1,
content: [
'<div style="margin-bottom:5px;font-size:12px">',
content,
'</div>',
'<div>',
'<input value="',
value,
'" style="width:18em;padding:6px 4px" />',
'</div>'
].join(''),
init: function () {
input = this.DOM.content.find('input')[0];
input.select();
input.focus();
},
ok: function (here) {
return yes && yes.call(this, input.value, here);
},
cancel: true
});
};
/**
* 短暂提示
* @param {String}提示内容
* @param {Number}显示时间 (默认1.5秒)
*/
artDialog.tips = function (content, time) {
return artDialog({
id: 'Tips',
title: false,
cancel: false,
fixed: true,
// lock: true,
width:250,
height:50
})
.content('<div style="padding: 0 1em;">' + content + '</div>')
.time(time || 1);
};
//右下角滑动通知
artDialog.notice = function (options) {
var opt = options || {},
api, aConfig, hide, wrap, top,
duration = 800;
var config = {
id: 'Notice',
left: '100%',
top: '100%',
fixed: true,
drag: false,
width:250,
height:50,
resize: false,
follow: null,
lock: false,
init: function(here){
api = this;
aConfig = api.config;
wrap = api.DOM.wrap;
top = parseInt(wrap[0].style.top);
hide = top + wrap[0].offsetHeight;
wrap.css('top', hide + 'px')
.animate({top: top + 'px'}, duration, function () {
opt.init && opt.init.call(api, here);
});
},
close: function(here){
wrap.animate({top: hide + 'px'}, duration, function () {
opt.close && opt.close.call(this, here);
aConfig.close = $.noop;
api.close();
});
return false;
}
};
for (var i in opt) {
if (config[i] === undefined) config[i] = opt[i];
};
return artDialog(config);
};
//调用范例:
art.dialog.alert('人品越来越不那么稳定了,请检查!');
art.dialog.confirm('你确定要删除这掉消息吗?', function () {
art.dialog.tips('执行确定操作');
}, function () {
art.dialog.tips('执行取消操作');
});
art.dialog.prompt('请输入图片网址', function (val) {
art.dialog.tips(val);
}, 'http://');
art.dialog.tips('数据正在提交..', 2);
//[more code..]
art.dialog.tips('成功!已经保存在服务器');