最近做项目遇到一个比较好的弹出框,在这里做一下记录:
如果遇到iframe的页面:可以这样包含一个新的域。
content: content: "<iframe src=\""+url+"\" width=\"1200px\" height=\"500px\" scrolling=\"auto\" frameborder=\"0\"></iframe>"
<!-- dialog弹出层引入 -->
<script type="text/javascript" src="<%=contextPath%>/scripts/artDialog-master/zz/dialog-plus.js?rnd="+Math.random()"></script>
<link rel="stylesheet" href="<%=contextPath%>/scripts/artDialog-master/css/ui-dialog.css"/>
function aa () {
var d = dialog({
title: '消息',
content: '风吹起的青色衣衫,夕阳里的温暖容颜,你比以前更加美丽,像盛开的花<br>——许巍《难忘的一天》',
// content: "<iframe src=\""+url+"\" width=\"1200px\" height=\"500px\" scrolling=\"auto\" frameborder=\"0\"></iframe>",
okValue: '确 定',
ok: function () {
dialog()
.title('提示2')
.content('hello world')
.button([{
value: '打开',
autofocus: true,
callback: function () {
dialog()
.title('提示')
.showModal();
}
}])
.show();
return false;
},
cancelValue: '取消',
cancel: function () {}
});
d.showModal();
}
如果遇到基于后台控制只能跳转到页面的方式,但是又不想使用iframe的。则可以先用ajax去取出源代码,然后再放入到弹出层的content当中。
例如:
//选择科室
function getOrgConstructorByNewCust(orgCode, orgName,type,orgMemType,orgTitle){
var orgCode1=jQuery("#registOrganize").val();
if(!isNull(orgCode) && !isNull(orgCode1)){
var url=contextPath+'/baseManager/BMAction.do?action=getOrgConstructor&Id1='+orgCode+"&Id2="+orgName+"&type="+type+"&orgMemType="+orgMemType+"&orgCode="+orgCode1+"&createFlag="+createFlag;
jQuery.ajax({
url:url,
async:false,
data:{
},
dataType:"html",
success: function(data){
var d = dialog({
id:'selectdept',
width: '730px',
height:'300px',
title: '选择科室',
content: data,
ok: false,
cancel: function(){
},
cancelValue:'取消'
});
d.showModal();
},
error:function(xhr,status){
MWalert(1,"后台异常");
return;
}
});
}else{
MWalert(1,"请先选择机构");
return;
}