頁面出div提示層

來源:互聯網
上載者:User

標籤:div彈層   jquery   

  在後台方法執行的過程中,如果系統不能在使用者容忍的時間間隔內做出相應的話,我們希望系統能夠給與提示,用以友好的人機互動,這個時候我們可以採取使用div彈出的方式來完成目標:


  1、使用jquery編寫要彈出的div層,代碼如下:

    function showTips(tips){ 

        //用來定位彈框位置

var windowWidth = document.documentElement.clientWidth; 

var windowHeight = document.documentElement.clientHeight;

var tipsDiv = ‘<div class="tipsClass" id="div_tips">‘ + tips + ‘</div>‘; 

$( ‘body‘ ).append( tipsDiv ); 

$( ‘div.tipsClass‘ ).css({ 

‘top‘ : (windowHeight/2) + ‘px‘, 

‘left‘ : ( windowWidth / 2 ) - ( tips.length * 13 / 2 ) + ‘px‘, 

‘position‘ : ‘absolute‘, 

‘padding‘ : ‘10px 20px‘, 

‘background‘: ‘#0099FF‘, 

‘font-size‘ : 12 + ‘px‘, 

‘margin‘ : ‘0 auto‘, 

‘text-align‘: ‘center‘, 

‘width‘ : ‘auto‘, 

‘color‘ : ‘#FFF‘, 

‘opacity‘ : ‘0.8‘ 

}).show();

//3s後移除提示框,自行運作的時候使用

//setTimeout( function(){$(‘#div_tips‘).remove();}, ( 3000 ) );

}

  2、方法調用

    在你需要調用此彈出層的時候:showTips( "提示內容"); 

  3、內容清楚

    執行完畢後,清除div內容:$("#div_tips").remove();


(附註說明:也可以使用EasyUI提供的訊息Messager功能來完成。)


本文出自 “Amtows--forever” 部落格,請務必保留此出處http://amtows.blog.51cto.com/6268328/1701548

頁面出div提示層

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.