复制代码 代码如下:
//前任作者:http://www.moozi.net
//修改:hh13774978@126.com,rayking
function$(str){
returndocument.getElementById(str);
}
function_(str){
returndocument.getElementsByTagName(str);
}
functionmsg(boxtitle,boxtype,boxwidth,msg,url){
$("msg_div_main").style.width=boxwidth;
$("msg_div_main").style.left=(_("body")[0].clientWidth-boxwidth)/2;
$("msg_div_main").style.top=(_("body")[0].clientHeight-220)/2;
varmsg_div_main_but_tmp="<br/><br/>"
+"<buttonclass='msg_div_main_but'id='msg_div_main_but'"
+"onclick="msg_close_tmp_biyuan();"+url+"">确定</button>";
switch(boxtype*1){
case1:
$("msg_div_main_content").innerHTML=msg+msg_div_main_but_tmp;
//$("msg_div_main_but").focus();
break;
case2:
$("msg_div_main_content").innerHTML=msg+msg_div_main_but_tmp
+"<buttonclass='msg_div_main_but'"
+"onclick='msg_close_tmp_biyuan();'>取消</button>";
//$("msg_div_main_but").focus();
break;
case3:
$("msg_div_main_content").innerHTML=msg;
break;
defualt:
$("msg_div_main_content").innerHTML=msg;
break;
}
$("msg_div_main_title").innerHTML=boxtitle;
$("msg_div_main").style.zIndex=200;
$("msg_div_main").style.display="";
if(document.all){//IE
if(!$("msg_div_all_Iframe"))
{
document.body.appendChild(document.createElement("<iframeid='msg_div_all_Iframe'style='display:none;'></iframe>"));
}
$("msg_div_all").style.zIndex=100;
$("msg_div_all").style.display="";
$("msg_div_all").oncontextmenu=function()
{
returnfalse;
}
$("msg_div_all_Iframe").style.zIndex=99;
$("msg_div_all_Iframe").style.display="";
$("msg_div_all_Iframe").oncontextmenu=function()
{
returnfalse;
}
}else{
$("msg_div_all").style.zIndex=100;
$("msg_div_all").style.display="";
$("msg_div_all").oncontextmenu=function()
{
returnfalse;
}
}
$("msg_div_main").oncontextmenu=function(){
returnfalse;
}
}
functionmsg_close_tmp_biyuan(){
$('msg_div_all').style.display='none';
$('msg_div_main').style.display='none';
if(document.all){
$('msg_div_all_Iframe').style.display='none';}
}
//加入对话框移动代码
/*鼠标拖动*/
varoDrag="";
varox,oy,nx,ny,dy,dx;
functiondrag(e,o){
vare=e?e:event;
varmouseD=document.all?1:0;
if(e.button==mouseD)
{
if(o.parentNode)
{
oDrag=o.parentNode;
}
else{oDrag=o;}
ox=e.clientX;
oy=e.clientY;
}
}
functiondragPro(e){
if(oDrag!="")
{
//varobj=document.getElementById("msg");//拖动的id
varobj=oDrag;//拖动的id
vare=e?e:event;
obj.style.position='absolute';
dx=parseInt(obj.style.left);
dy=parseInt(obj.style.top);
if(isNaN(dx)){dx=0;}
if(isNaN(dy)){dy=0;}
nx=e.clientX;
ny=e.clientY;
obj.style.left=(dx+(nx-ox))+"px";
obj.style.top=(dy+(ny-oy))+"px";
ox=nx;
oy=ny;
}
}
document.onmouseup=function(){oDrag="";}
document.onmousemove=function(event){dragPro(event);}
document.writeln("<styletype='text/css'>"
+"#msg_div_all,#msg_div_all_Iframe{width:100%;height:100%;position:absolute;filter:Alpha(opacity=70);opacity:0.7;background:#EFEFEF;}"
+"#msg_div_main{position:absolute;}"
+"#msg_div_main_title{font-size:12px;color:#2C71AF;font-family:verdana;cursor:default;}"
+"#msg_div_main_content{font-size:14px;color:#2C71AF;padding-left:8px;}"
+".msg_div_main_but{background:url(img/buttonbg.gif);width:65px;heigt:20px;border:none;padding-top:3px;font-size:12px;}"
+"</style>"
+"<divid='msg_div_all'style='display:none;'></div>"
+""
+"<divid='msg_div_main'style='display:none;'>"
+"<tablewidth='100%'height='29'border='0'cellspacing='0'cellpadding='0'onmousedown='drag(event,this)'>"
+"<tr>"
+"<tdwidth='25'><imgsrc='img/bg_01.gif'width='25'height='29'alt=''/></td><tdbackground='img/bg_02.gif'width='3'></td>"
+"<tdbackground='img/bg_02.gif'msg_forid='msg_div_main'id='msg_div_main_title'></td>"
+"<tdbackground='img/bg_02.gif'align='right'style='padding-top:4px'>"
+"<imgsrc='img/bg_05.gif'width='21'height='21'alt='关闭'"
+"onMouseover="this.src='img/bg_13.gif'""
+"onMouseout="this.src='img/bg_05.gif'"onMouseup='msg_close_tmp_biyuan();'"
+"onMousedown="this.src='img/bg_18.gif'"></td>"
+"<tdwidth='6'><imgsrc='img/bg_06.gif'width='6'height='29'alt=''/></td>"
+"</tr>"
+"</table>"
+"<tablewidth='100%'border='0'cellspacing='0'cellpadding='0'>"
+"<tr>"
+"<tdwidth='3'background='img/bg_07.gif'></td>"
+"<tdbgcolor='#F7F7F7'align='center'><br/><spanid='msg_div_main_content'></span><br/><br/></td>"
+"<tdwidth='3'background='img/bg_08.gif'></td>"
+"</tr>"
+"<tr>"
+"<tdwidth='3'height='3'><imgsrc='img/bg_09.gif'width='3'height='3'alt=''/></td>"
+"<tdbackground='img/bg_11.gif'></td>"
+"<tdwidth='3'height='3'><imgsrc='img/bg_10.gif'width='3'height='3'/></td>"
+"</tr>"
+"</table>"
+"</div>");
在线演示
打包下载