最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js確認(rèn)刪除對(duì)話框效果的示例代碼

 更新時(shí)間:2014年02月20日 09:20:49   作者:  
本篇文章主要是對(duì)js確認(rèn)刪除對(duì)話框效果的示例代碼進(jìn)行了介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助
效果如下:



css文件delcss.css

代碼如下:

復(fù)制代碼 代碼如下:

*{ 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

代碼如下:

復(fù)制代碼 代碼如下:

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.引入文件

復(fù)制代碼 代碼如下:

<link rel="stylesheet" type="text/css" href="delcss.css"/>
<script src="confirmPop.js"></script>

2.調(diào)用方法
復(fù)制代碼 代碼如下:

<script>
window.onload=window.onresize=function(){
    new ConfirmPop('btn','div1','overlay','title','closeConfirm','trueConfirm');
}
</script>

3.做好準(zhǔn)備工作
復(fù)制代碼 代碼如下:

<div id="div1">
    <h3 id="title"></h3>
    <div id="confirmCon">
        您確定要進(jìn)行刪除操作么?
    </div>
    <a href="###" id="trueConfirm">確定</a>
    <a href="###" id="closeConfirm">取消</a>
</div>
<div id="overlay"></div>

這段代碼是提供空間的,自己寫的div代碼。其中確定框中的a標(biāo)簽中,可以把刪除的地址填入其中。點(diǎn)擊確定時(shí),就跳轉(zhuǎn)到刪除的頁(yè)面方法中了。

這段代碼可以放入任何位置。不占空間。作者很犀利。

4.導(dǎo)火線,觸發(fā)器

復(fù)制代碼 代碼如下:

<a  id="btn" ><img src="/images/default/right/ico_del.gif" /></a>

將刪除圖標(biāo)加上id="btn",這樣就會(huì)觸發(fā)刪除效果了。

如果想修改樣式,可以到css中進(jìn)行修改,調(diào)整。

小結(jié):這樣的js刪除就比瀏覽器自帶的彈出框美觀一些了。作者用短短3k的js就寫出這種效果,真心厲害。

ps,我只是拿來的。

缺點(diǎn),只能針對(duì)一個(gè)內(nèi)容,進(jìn)行刪除。因?yàn)樗械亩际轻槍?duì)id的,單一化了。

  • JavaScript聲明函數(shù)的5種方法小結(jié)

    JavaScript聲明函數(shù)的5種方法小結(jié)

    本文主要介紹了JavaScript聲明函數(shù)的5種方法小結(jié),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-02-02
  • Locate a File Using a File Open Dialog Box

    Locate a File Using a File Open Dialog Box

    Locate a File Using a File Open Dialog Box...
    2007-06-06
  • JavaScript中匿名函數(shù)的遞歸調(diào)用

    JavaScript中匿名函數(shù)的遞歸調(diào)用

    本文主要介紹了JavaScript中匿名函數(shù)的遞歸調(diào)用。具有很好的參考價(jià)值,下面跟著小編一起來看下吧
    2017-01-01
  • Js實(shí)現(xiàn)當(dāng)前點(diǎn)擊a標(biāo)簽變色突出顯示其他a標(biāo)簽回復(fù)原色

    Js實(shí)現(xiàn)當(dāng)前點(diǎn)擊a標(biāo)簽變色突出顯示其他a標(biāo)簽回復(fù)原色

    當(dāng)一個(gè)頁(yè)面有多個(gè)a標(biāo)簽,實(shí)現(xiàn)當(dāng)前點(diǎn)擊a標(biāo)簽變色,其他a標(biāo)簽回復(fù)原色,具體實(shí)現(xiàn)如下,喜歡的朋友可以參考下
    2013-11-11
  • 靜態(tài)頁(yè)面html中跳轉(zhuǎn)傳值的JS處理技巧

    靜態(tài)頁(yè)面html中跳轉(zhuǎn)傳值的JS處理技巧

    這篇文章主要介紹了靜態(tài)頁(yè)面html中跳轉(zhuǎn)傳值的JS處理技巧,結(jié)合實(shí)例形式分析了HTML頁(yè)面跳轉(zhuǎn)通過URL傳遞參數(shù)的方法與javascript處理技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2016-06-06
  • 前端BOM操作常用命令詳解及代碼案例

    前端BOM操作常用命令詳解及代碼案例

    瀏覽器對(duì)象模型(BOM)是瀏覽器提供的JavaScript操作瀏覽器的API,提供了與網(wǎng)頁(yè)無關(guān)的瀏覽器功能對(duì)象,這篇文章主要給大家介紹了關(guān)于前端BOM操作常用命令詳解及代碼案例的相關(guān)資料,需要的朋友可以參考下
    2024-10-10
  • JavaScript事件委托實(shí)例分析

    JavaScript事件委托實(shí)例分析

    這篇文章主要介紹了JavaScript事件委托的用法,以實(shí)例形式分析了javascript事件委托的實(shí)現(xiàn)方法,需要的朋友可以參考下
    2015-05-05
  • javascript客戶端遍歷控件與獲取父容器對(duì)象示例代碼

    javascript客戶端遍歷控件與獲取父容器對(duì)象示例代碼

    本篇文章主要是對(duì)javascript客戶端遍歷控件與獲取父容器對(duì)象示例代碼進(jìn)行了介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助
    2014-01-01
  • Javascript 浮點(diǎn)運(yùn)算精度問題分析與解決

    Javascript 浮點(diǎn)運(yùn)算精度問題分析與解決

    浮點(diǎn)數(shù)的精度問題不是JavaScript特有的,因?yàn)橛行┬?shù)以二進(jìn)制表示位數(shù)是無窮的
    2014-03-03
  • 最新評(píng)論

    海南省| 崇信县| 全椒县| 永春县| 六枝特区| 东阿县| 梅河口市| 晋宁县| 泸定县| 福贡县| 剑河县| 山东| 绥棱县| 余干县| 沭阳县| 兴和县| 体育| 吉林省| 南溪县| 石狮市| 玉田县| 阆中市| 平潭县| 凤凰县| 大兴区| 绍兴县| 会昌县| 施甸县| 固阳县| 昆明市| 垫江县| 黔西| 连江县| 惠安县| 阿拉善右旗| 米易县| 桐城市| 景宁| 甘泉县| 石阡县| 定南县|