//**自己写的确认框,用法:事件中调用show_confirm('func_name()','tip_info'),并且func_name函数后要调用hide_confirm();
function show_confirm(callback,tips){
if(document.getElementById('_shield'))
return;
var oDiv = document.createElement('div');
var domBody = document.documentElement?document.documentElement:document.body;
document.body.appendChild(oDiv);
oDiv.setAttribute('id','_shield');
oDiv.style.position = 'absolute';
oDiv.style.left = '0px';
oDiv.style.top = '0px';
oDiv.style.width = domBody.scrollWidth + 'px';
oDiv.style.height = domBody.scrollHeight + 'px';
oDiv.style.backgroundColor = '#888';
oDiv.style.filter = "alpha(opacity=50)";
oDiv.style.opacity = 0.5;
var left_scroll = domBody.scrollLeft; //滚动条卷去的宽度
var top_scroll = domBody.scrollTop; //滚动条卷去的高度
var width_view = domBody.clientWidth; //正文可见宽度
var height_view = domBody.clientHeight; //正文可见高度
var l = left_scroll + (width_view-260)/2;
var t = top_scroll + (height_view-180)/2
var tip = tips?tips:'';
$(document.body).append('<div class="clue_to" id="_confirm"><p class="color1">确定要删除吗?</p><p class="color2">'+tip+'</p><p><input class="btncm btnok" value="确 定" type="button" onclick="'+callback+'" /> <input class="btncm btncc" value="取 消" type="button" onclick="hide_confirm()" /></p></div>');
document.getElementById('_confirm').style.left = l + 'px';
document.getElementById('_confirm').style.top = t + 'px';
}
function hide_confirm(){
document.getElementById('_shield').parentNode.removeChild(document.getElementById('_shield'));
document.getElementById('_confirm').parentNode.removeChild(document.getElementById('_confirm'));
}
CSS:
/*日志删除确认提示框*/
.clue_to{
width:260px;
position:absolute;
padding:18px 0px 0px 0px;
border:1px solid #ddd;
text-align:center;
background:#fff;
}
.clue_to p input{
width:80px;
height:26px;
}
.clue_to p{
margin-bottom:18px;
}
.clue_to p.color1{
font-size:16px;
font-weight:bold;
}
.clue_to p.color2{
font-size:14px;
color:#3366CC;
}