工作問題之自定義confirm功能框

昨天牛X前端給做了一個帶有確認取消按鈕的彈出框:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>作業模塊--佈置作業</title>
<script src="http://www.eoopen.com/public/Host/js/jquery.js"></script>
<style>
.popbox{position:absolute;top:0;left:0;display:none;z-index:120;}
#screen{width:100%;height:100%;position:absolute;top:0;left:0;display:none;z-index:100;background-color:#666;opacity:0.5;filter:alpha(opacity=50);-moz-opacity:0.5;}
.overdue{ width:461px; height:233px; border:#dddddd solid 1px; background:url(../images/overdue.jpg) no-repeat;}
.close{ float:right; margin:10px;}
.overdue_con{ float:left; width:461px; }
.overdue_con dl{ float:left; width:461px; margin:20px 0 20px 0;}
.overdue_con dl dt{ float:left; margin:0 20px 0 130px;}
.overdue_con dl dd{ float:left; font-size:14px; line-height:29px;}
.overdue_con span{ float:left; width:461px; display:block; text-align:center;}
.overdue_con span a{ width:90px; height:35px; text-align:center; line-height:35px; display:block; float:left; color:#FFF; border-radius:10px; background:#a6bccc; margin-right:30px; margin-top:20px;}
.overdue_con span .one_btn{ background:#299ff2; margin-left:130px;}
</style>
</head>

<body scroll="no">
<a href="" class="popbox-link">發佈</a><a href="">返回</a>
 <div id="screen"></div>
     <div class="popbox">
        <div class="overdue">
    <div class="close"><!--<img src="images/xf_03.png" width="21" height="21" />--></div>
    <div class="overdue_con">
        <dl>
            <dt><img src="../images/payment_03.png" width="56" height="56" /></dt>
            <dd>
                <p style="color:red;">發佈成功!</p>
            </dd>
        </dl>
        <span><a href="homework_list.html" class="one_btn">確定</a><a href="javascript:viod(0)" class="close-btn">取消</a></span>
    </div>
    </div>
</div><!--popbox end-->
<div class="hhh">1211</div>
 <!----->
</body>
</html>
<script type="text/javascript">


    function two(){
        var h = $(document).height();
        $('#screen').css({ 'height': h });    
        $('#screen').show();
        $('.popbox').center();
        $('.popbox').fadeIn();
        return false;
    };
    

jQuery.fn.center = function(loaded) {
    var obj = this;
    body_width = parseInt($(window).width());
    body_height = parseInt($(window).height());
    block_width = parseInt(obj.width());
    block_height = parseInt(obj.height());
    
    left_position = parseInt((body_width/2) - (block_width/2)  + $(window).scrollLeft());
    if (body_width<block_width) { left_position = 0 + $(window).scrollLeft(); };
    
    top_position = parseInt((body_height/2) - (block_height/2) + $(window).scrollTop());
    if (body_height<block_height) { top_position = 0 + $(window).scrollTop(); };
    
    if(!loaded) {
        
        obj.css({'position': 'absolute'});
        obj.css({ 'top': top_position, 'left': left_position });
        $(window).bind('resize', function() {
            obj.center(!loaded);
        });
        $(window).bind('scroll', function() {
            obj.center(!loaded);
        });
        
    } else {
        obj.stop();
        obj.css({'position': 'absolute'});
        obj.animate({ 'top': top_position }, 200, 'linear');
    }
}
if($('.hhh').text('1211')){
    two()    
}
</script>

在套用的時候,直接把這個方法套在原來CONFIRM的位置,一直被推遲執行,既在此方法下寫一個ALERT,永遠先執行到ALERT,想了半天一直卡在這裏,因爲下方的判斷條件老是沒等到方法的點擊事件執行就已經跳過,後來恍然大悟發現直接把判斷語句丟進點擊事件裏,一切就解決了。

感悟之。。。。。。。用一個新的方法,一切都要從新開始,不可以套在原有的格局。

發佈了35 篇原創文章 · 獲贊 4 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章