最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

js确认删除对话框效果的示例代码_javascript技巧

来源:懂视网 责编:小采 时间:2020-11-27 21:19:56
文档

js确认删除对话框效果的示例代码_javascript技巧

js确认删除对话框效果的示例代码_javascript技巧:效果如下: css文件delcss.css 代码如下: 代码如下:*{ margin:0; padding:0;}#div1{ width:300px; height:100px; border-radius:10px; background:#f60; box-shadow:5px 5px 10px #ccc; position:absol
推荐度:
导读js确认删除对话框效果的示例代码_javascript技巧:效果如下: css文件delcss.css 代码如下: 代码如下:*{ margin:0; padding:0;}#div1{ width:300px; height:100px; border-radius:10px; background:#f60; box-shadow:5px 5px 10px #ccc; position:absol
效果如下:



css文件delcss.css

代码如下:
代码如下:
*{ margin:0; padding:0;}
#div1{ width:300px; height:100px; border-radius:10px; background:#f60; box-shadow:5px 5px 10px #ccc; position:absolute; left:50%; margin-left:-150px; z-index:2; opacity:0; filter:alpha(opacity:0); display:none;}
#div1 h3{ height:20px; background:#60f;}
#overlay{ width:100%; height:100%; background:#ccc; position:absolute; left:0; top:0; opacity:0; z-index:1; display:none;}
#closeConfirm{ width:80px; height:20px; line-height:20px; background:#ccc; border-radius:5px; display:block; text-decoration:none; color:#000; text-align:center; position:absolute; bottom:10px; right:10px;}
#trueConfirm{width:80px; height:20px; line-height:20px; background:#ccc; border-radius:5px; display:block; text-decoration:none; color:#000; text-align:center; position:absolute; bottom:10px; right:100px;}
#confirmCon{ text-align:center; color:#ccc; height:40px; line-height:40px;}

js文件confirmPop.js

代码如下:
代码如下:
function ConfirmPop(delObj,confirmMain,overlay,binkTitle,closeConfirm,trueConfirm){
this.oDelObj=document.getElementById(delObj);
this.oDiv=document.getElementById(confirmMain);
this.oOverlay=document.getElementById(overlay);
this.oTitle=document.getElementById(binkTitle);
this.oCloseConfirm=document.getElementById(closeConfirm);
this.oTrueConfirm=document.getElementById(trueConfirm);
this.oConStart=0;
this.oConItarget=0;
this.init();
}
ConfirmPop.prototype={
init:function(){
this.oConStart=parseInt((document.documentElement.clientHeight-this.oDiv.offsetHeight)/2-100);
this.oConItarget=parseInt((document.documentElement.clientHeight-this.oDiv.offsetHeight)/2-70);
this.oDiv.style.top=this.oConStart+'px';
document.title=this.oConStart+', '+this.oConItarget;
var _this=this;
this.oDelObj.onclick=function(){
_this.confirmShow();
}
this.oOverlay.onclick=function(){
_this.titleBink();
}
this.oCloseConfirm.onclick=this.oTrueConfirm.onclick=function(){
_this.confirmHide();
}

},
confirmShow:function(){
this.oOverlay.style.display='block';
this.oDiv.style.display='block';
striveMove(this.oOverlay,{ opacity:30});
striveMove(this.oDiv,{top:this.oConItarget, opacity:100})
},
titleBink:function(){
var _this=this;
var iLightTimer=null;
var i=0;
iLightTimer=setInterval(function(){
if(i%2){
_this.oTitle.style.background='#60f';
}else{
_this.oTitle.style.background='#ccc';
}
i++;
if(i>5){
clearInterval(iLightTimer);
}
},50)
},
confirmHide:function(){
striveMove(this.oOverlay,{opacity:0});
this.oOverlay.style.display='none';
striveMove(this.oDiv,{top:this.oConStart, opacity:0});
}

}
function striveMove(obj,json,fn){clearInterval(obj.iTimer);obj.iTimer=setInterval(function(){var bStop=true;for(var attr in json){var iCur=0;if(attr=='opacity'){iCur=Math.round(parseFloat(getStyle(obj,attr))*100);}else{iCur=parseInt(getStyle(obj,attr));}var iSpeed=(json[attr]-iCur)/8;iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed);if(attr=='opacity'){obj.style.filter='alpha(opacity:'+(iCur+iSpeed)+')';obj.style.opacity=(iCur+iSpeed)/100;}else{obj.style[attr]=iCur+iSpeed+'px';}if(iCur!==json[attr]){bStop=false;}}if(bStop){clearInterval(obj.iTimer);if(fn){fn();}}},30)}function getStyle(obj,attr){return obj.currentStyle?obj.currentStyle[attr]:getComputedStyle(obj,false)[attr];}

使用方法

1.引入文件
代码如下:

声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文档

js确认删除对话框效果的示例代码_javascript技巧

js确认删除对话框效果的示例代码_javascript技巧:效果如下: css文件delcss.css 代码如下: 代码如下:*{ margin:0; padding:0;}#div1{ width:300px; height:100px; border-radius:10px; background:#f60; box-shadow:5px 5px 10px #ccc; position:absol
推荐度:
标签: 删除 确定 js
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top