仿中關村線上首頁彈出式廣告外掛程式(jQuery版)

來源:互聯網
上載者:User

其的就不多說啦,直接上代碼:
jquery 外掛程式:
複製代碼 代碼如下:
/*
瘋狂秀才 製作 於 2012-04-24 17:00
QQ: 1055818239
email: hxl_apple@163.com
*/
(function($){
$.fn.quickAd = function(settings){
settings = $.extend({
width:760,
height:400,
html:'我是廣告內容',
top:130,
sec:5, //廣告顯示時間長度,單位秒
border:true //顯示外框
},settings);
var fkxc_ad = 0;
var bodyWidth = $(window).width();
var _adBodyContainerID = "bigAd_"+settings.width;
var _adCloseContainerID = "bitAdClose_"+settings.width;
var closeHtml = '廣告剩餘 <span id="__sec"></span> 秒 <a href="javascript:;" id="__close_ad">關 閉</a>';
//廣告內容容器
var _adContent = '<div id="'+_adBodyContainerID+'"></div>';
//關閉按鈕容器
var _adCloseBtn = '<div id="'+_adCloseContainerID+'">'+closeHtml+'</div>';
var self = $(this);
$(this).empty().html(_adContent+_adCloseBtn);
$('#__close_ad').click(function(){
window.clearTimeout(fkxc_ad);
self.fadeOut();
})
if(settings.border){
$('#'+_adBodyContainerID).css('border','1px solid #ccc');
}
$('#'+_adBodyContainerID).empty().html(settings.html).css({
'width':settings.width+'px',
'height':settings.height+'px',
'position': 'fixed',
'z-index': 20000,
'top':settings.top+'px',
'left':(bodyWidth - settings.width) / 2 + 'px'
}).fadeIn('fast');
$('#'+_adCloseContainerID).css({
'width':'160px','height':'18px','line-height':'18px','background-color':'#ccc',
'text-align': 'center', 'opacity': '0.8','top':settings.top+'px','position': 'fixed',
'left':((bodyWidth - settings.width) / 2+(settings.width-160)) + 'px', 'z-index': 20001
}).show();
var daojishi = function (s) {
fkxc_ad = setInterval(function () {
if (s == 0) {
self.fadeOut();
}
$("#__sec").text(s);
s--;
}, 1000);
}
daojishi(settings.sec)
}
})(jQuery)

HTML:
複製代碼 代碼如下:
<div id="testad"></div>
<script>
$(function(){
$('#testad').quickAd({
html:'<img src="11_523049_88a5614dc705882 (1).jpg" width=760 height=400 />'
});
})
</script>

Ok啦!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.