生成浮动层的接口知识总结
2009-09-06 00:00:00 来源:WEB开发网我们在做应用开发时很经常地要生成浮动层,里面显示一些我们需要显示的内容。这里写一个生成浮动层的接口。如下:
Js代码
function minimizeExec(floatLyrComm){
var execObjCnt = $(floatLyrComm+"Cnt");
var execObjDiv = $(floatLyrComm);
var eventElement = event.srcElement || event.target;
if(execObjCnt.style.display==''){
execObjCnt.style.display = 'none';
eventElement.innerText = "□";
execObjDiv.style.height = '20px';
}else if(execObjCnt.style.display=='none'){
execObjCnt.style.display = '';
eventElement.innerText = "-";
}
}
/*************************************************************************************/
/*
/* 文档追加类(目前用于生成浮动层)
/*
/*************************************************************************************/
function DocWriteGen(){
}
DocWriteGen.prototype={
/**
* purpose:生成浮动层
* author:liugx
* remark:
*/
genFloatLyr:function(floatLyrId,floatLyrPro){
var floatdiv = document.createElement("div");
floatdiv.id = floatLyrId;
floatdiv.className = "float-lyr";
floatdiv.style.position = "absolute";
//floatdiv.style.left = floatLyrPro.left?floatLyrPro.left:"0px";
floatdiv.style.left = floatLyrPro.left||"0px";
floatdiv.style.top = floatLyrPro.top||"0px";
floatdiv.style.width = floatLyrPro.width||"200px";
floatdiv.style.height = floatLyrPro.height||"100px";
if(floatLyrPro.opacity){
floatdiv.style.opacity = floatLyrPro.opacity;
floatdiv.style.filter = 'alpha(opacity=' + parseInt(parseFloat(floatLyrPro.opacity)*100) + ')';
}
floatdiv.style.borderColor = floatLyrPro.borderColor||"#6495ED";
floatdiv.style.display = 'none';
trColor = floatLyrPro.trColor||"#6495ED";
tdTitle = floatLyrPro.tdTitle||"";
floatdiv.innerHTML = '<table width="100%" height="100%" boder="0" cellspacing="0" cellpadding="0">' +
'<tr style="background-color:' + trColor + '">'+
'<td height="20" width="96%" style="color:#FFFFFF" onmouseover="this.style.cursor=\'hand\';"'+
'onmousedown="Element.move(document.getElementById(\''+floatdiv.id+'\'),event);">'+tdTitle+'</td>' +
'<td width="2%" style="color:#FFFFFF;cursor:hand" onclick="minimizeExec(\''+floatdiv.id+'\')">-</td>' +
'<td width="2%" style="color:#FFFFFF;cursor:hand" onclick="document.getElementById(\''+floatdiv.id+'\').style.display=\'none\'">×</td>' +
'</tr>' +
'<tr>' +
'<td colspan="3" valign="top"><div id="'+floatdiv.id+'Cnt"></div></td>' +
'</tr>' +
'</table>';
return floatdiv;
}
}
var docWriteGen = new DocWriteGen();
更多精彩
赞助商链接