复制内容到剪贴板
代码:
<!--
var alertBox={
isOpera:(navigator.userAgent.indexOf('Opera')>-1),
// 根据ID获得DOM节点
$: function(i){
if(!document.getElementById)return false;
if(typeof i==="string"){
if(document.getElementById && document.getElementById(i)) {// W3C DOM
return document.getElementById(i);
}
else if(document.all && document.all(i)){// MSIE 4 DOM
return document.all(i);
}
else if(document.layers && document.layers[i]){// NN 4 DOM.. note: this won't find nested layers
return document.layers[i];
}
else {
return false;
}
}
else{return i;}
},
maxDragWidth: null, // 拖动的最大宽度
maxDragWidth: null, // 拖动的最大高度
oBtnShow: null, // 创建提示信息框按钮节点
oShadow: null, // 遮照层
oAlertWindow: null, // 提示框层
oDragHandle: null, // 提示框的拖动柄
oBtnEnter: null, // 提示框的确定按钮
oBtnClose: null, // 提示框的关闭按钮
strMessage: null, // 提示框的提示内容
bSlideWindow: false, // 是否渐变显示提示框,默认渐变
bDragWindow: false, // 是否拖动提示框,默认拖动
iWindowIcon: 1, // 弹出窗口图标的风格
init: function(strMsg,bSlide,bDrag){
this.oBtnShow=this.$("btnshow");
this.strMessage=strMsg;
this.bSlideWindow=bSlide?false:true;
this.bDragWindow=bDrag?false:true;
if(!this.oBtnShow){
if(this.oShadow && this.oAlertWindow){
this.closeDiv();
}
this.createDiv();
this.setEvent();
}
else{
this.oBtnShow.onclick=function(){
alertBox.createDiv();
alertBox.setEvent();
}
}
},
createDiv: function(obj){
if(this.oBtnShow) this.oBtnShow.disabled=true;
var shadow = document.createElement("id");
shadow.setAttribute("id","shadow");
shadow.style.height=parseInt(document.body.offsetHeight)+"px";
var obj=document.createElement("div");
obj.setAttribute("id","window");
obj.style.zIndex="999";
if(document.all){
if(this.isOpera){
obj.style.opacity = 0.1;
}
else{
obj.style.filter = "alpha(opacity=10)";
}
}
else{
obj.style.opacity = 0.1;
}
var divTitle = document.createElement("div");
divTitle.setAttribute("id","win-tl");
var H2 = document.createElement("h2");
var IMG=document.createElement("img");
IMG.setAttribute("src","alertImg/win.png");
IMG.setAttribute("alt","Window-Icon");
var txtTitle=document.createTextNode("爱唱卡充值");
H2.appendChild(IMG);
H2.appendChild(txtTitle);
var closeBar=document.createElement("div");
closeBar.setAttribute("id","closebar");
var A = document.createElement("a");
A.innerHTML="关闭窗口";
A.setAttribute("href","#1");
A.setAttribute("id","btnclose");
A.setAttribute("title","关闭窗口");
closeBar.appendChild(A);
var titleRight=document.createElement("div");
titleRight.setAttribute("id","win-tr");
divTitle.appendChild(H2);
divTitle.appendChild(closeBar);
divTitle.appendChild(titleRight);
var Container = document.createElement("div");
Container.setAttribute("id","msg-content");
var cntLeft=document.createElement("div");
cntLeft.setAttribute("id","msg-leftbar");
var MSG=document.createElement("div");
MSG.setAttribute("id","msg");
var INFO=document.createElement("div");
INFO.setAttribute("id","info");
var H3 = document.createElement("h3");
H3.innerHTML="恭喜您充值成功!";
var P = document.createElement("p");
P.innerHTML="充值单号为:<strong id=\"txtuid\">"+this.strMessage+"</strong>(请您牢记,便于查询)";
INFO.appendChild(H3);
INFO.appendChild(P);
var Btns=document.createElement("div");
Btns.setAttribute("id","btns");
var btnEnter=document.createElement("a");
btnEnter.setAttribute("id","btnok");
btnEnter.setAttribute("href","#1");
var txtEnter=document.createTextNode("确定");
btnEnter.appendChild(txtEnter);
Btns.appendChild(btnEnter);
MSG.appendChild(INFO);
MSG.appendChild(Btns);
var cntRight=document.createElement("div");
cntRight.setAttribute("id","msg-rightbar");
Container.appendChild(cntLeft);
Container.appendChild(MSG);
Container.appendChild(cntRight);
var msgBottom = document.createElement("div");
msgBottom.setAttribute("id","msg-bottom");
var msgBLeft=document.createElement("div");
msgBLeft.setAttribute("id","msg-bottom-left");
var msgBRight=document.createElement("div");
msgBRight.setAttribute("id","msg-bottom-right");
msgBottom.appendChild(msgBLeft);
msgBottom.appendChild(msgBRight);
document.body.appendChild(shadow);
obj.appendChild(divTitle);
obj.appendChild(Container);
obj.appendChild(msgBottom);
document.body.appendChild(obj);
this.oAlertWindow=obj;
this.oDragHandle=divTitle;
this.oShadow=shadow;
this.oBtnEnter=btnEnter;
this.oBtnClose=A;
},
setEvent: function(){
if(!this.oAlertWindow || !this.oDragHandle || !this.oShadow || !this.oBtnEnter || !this.oBtnClose) return false;
if(this.bDragWindow){
this.dragDiv();
}
else{
this.oAlertWindow.style.top=(document.body.offsetHeight-180)/2+"px";;
this.oAlertWindow.style.left=(document.body.offsetWidth-400)/2+"px";
}
if(this.bSlideWindow){
this.slideDiv();
}
else{
if(document.all){
if(this.isOpera){
this.oAlertWindow.style.opacity = 1;
}
else{
this.oAlertWindow.style.filter = "";
}
}
else{
this.oAlertWindow.style.opacity = 1;
}
}
// 设置关闭和确定按钮的功能--关闭(移除)提示框
this.oBtnEnter.onclick=this.oBtnClose.onclick=function(){
alertBox.closeDiv();
}
},
dragDiv: function(){
this.maxDragWidth=document.body.offsetWidth-400;
this.maxDragHeight=document.body.offsetHeight-180;
Drag.init(this.oDragHandle,this.oAlertWindow,true,0,this.maxDragWidth,0,this.maxDragHeight);
},
slideDiv: function(){
var i=10;
var j=0.1;
var _fliter_=function(){
if(document.all){
if(i>100 || j>1){
if(tt) tt=window.clearInterval(tt);
if(alertBox.isOpera){
this.oAlertWindow.style.opacity = 1;
}
else{
alertBox.oAlertWindow.style.filter ="";
}
return false;
}
if(alertBox.isOpera){
alertBox.oAlertWindow.style.opacity = j;
j += 0.1;
}
else{
alertBox.oAlertWindow.style.filter = "alpha(opacity="+i+")";
i += 10;
}
}
else{
if(j>1){
if(tt) tt=window.clearInterval(tt);
alertBox.oAlertWindow.style.opacity=1;
return false;
}
alertBox.oAlertWindow.style.opacity = j;
j += 0.1;
}
}
var tt=window.setInterval(_fliter_,50);
},
closeDiv: function(){
if(this.oAlertWindow.style.filter=="" || this.oAlertWindow.style.opacity==1){
document.body.removeChild(this.oAlertWindow);
document.body.removeChild(this.oShadow);
if(this.oBtnShow) this.oBtnShow.disabled=false;
}
}
}
window.onresize=function(){
if(alertBox.oAlertWindow && alertBox.oDragHandle){
alertBox.dragDiv();
}
}
//-->