有问题可联系我QQ:429810818

posts - 4, comments - 6, trackbacks - 0, articles - 8

jqueryEasyUI之自定义弹出框-TPopBox

Posted on 2012-09-27 17:23 张力 阅读(283) 评论(0)  编辑  收藏
/**
 * @author tension
 * @param optins
 * copyright @Tension
 */
function showTPopbox(optins){ 
var width = optins.width;//宽
var height = optins.height;//宽
var url = optins.url;
var titleStr = optins.title; //标题
var bodyHeight = height - 30;
var str='<iframe src="'+url+'" width="100%" frameborder="0" scrolling="auto" marginwidth=0 marginheight=0 style="height:'+bodyHeight+'px"></iframe>';
var sWidth,sHeight;   
sWidth=document.documentElement.clientWidth;   
sHeight=document.documentElement.clientHeight;   
 
/*半透明层  -----begin-------*/
var bgObj=document.createElement("div");   
bgObj.setAttribute('id','bgDiv');   
bgObj.style.position="absolute";   
bgObj.style.top="0";   
bgObj.style.background="#cccccc";   
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=1,opacity=20,finishOpacity=75";   
bgObj.style.opacity="0.2";   
bgObj.style.left="0";   
bgObj.style.width=sWidth + "px";   
bgObj.style.height=sHeight + "px";   
bgObj.style.zIndex = "10000";   
document.body.appendChild(bgObj);  
  
/*半透明层  -----end-------*/
 
var TPopbox=document.createElement("div"); 
TPopbox.setAttribute("id","TPopbox");   
TPopbox.setAttribute('class','panel window'); 
TPopbox.setAttribute("align","center"); 
TPopbox.style.position = "absolute";   
//TPopbox.style.left = "50%";   
//
//TPopbox.style.top = "20%";   
TPopbox.style.left = (sWidth - width) / 2 + "px";   
TPopbox.style.top = (sHeight - height) / 2 +"px";   
TPopbox.style.width = width + "px";   
TPopbox.style.height =height + "px";   
TPopbox.style.textAlign = "center";   
TPopbox.style.lineHeight ="25px";   
TPopbox.style.zIndex = "10001";   
document.getElementById("bgDiv").appendChild(TPopbox);
/**div 头部 -----begin----*/
var header=document.createElement("div");   
header.setAttribute("id","panel-header");   
header.setAttribute("align","left");   
header.setAttribute("class","panel-header panel-header-noborder window-header"); 
header.style.cursor="move"; 
document.getElementById("TPopbox").appendChild(header);
/**div 头部 -----end----*/
/**头部title -----begin------*/
var title=document.createElement("div");
title.setAttribute("id","panel-header-title");
title.innerHTML=titleStr; 
document.getElementById("panel-header").appendChild(title);
/**头部title -----end------*/
/**工具 -----begin-------*/
var tool=document.createElement("div");
tool.setAttribute("id","panel-tool-close");
tool.setAttribute("class","panel-tool");
tool.innerHTML='<a class="panel-tool-close" href="javascript:void(0)"></a>'; 
document.getElementById("panel-header").appendChild(tool);
tool.onclick= function(){close();};
/**工具 -----end-------*/
   
document.body.appendChild(TPopbox);   
document.getElementById("TPopbox").appendChild(header);   
var body=document.createElement("div");   
body.setAttribute("id","panel-body");
body.setAttribute("class","dialog-content panel-body panel-body-noheader panel-body-noborder");
body.style.height = height - 30 + "px";
body.style.background="white";  
body.style.fontSize="20";
body.innerHTML=str;   
document.getElementById("TPopbox").appendChild(body);   
}   
function close(){   
document.body.removeChild(document.getElementById("TPopbox"));  
document.body.removeChild(document.getElementById("bgDiv"));   
};

只有注册用户登录后才能发表评论。


网站导航: