It's not much to say, directly on the code:
jquery Plug-ins:
Copy Code code as follows:
/*
Crazy scholar made in 2012-04-24 17:00
qq:1055818239
Email:hxl_apple@163.com
*/
(function ($) {
$.fn.quickad = function (settings) {
Settings = $.extend ({
width:760,
height:400,
HTML: ' I'm advertising content ',
top:130,
Sec:5,//advertising display length, unit seconds
Border:true//Display outer box
},settings);
var fkxc_ad = 0;
var bodywidth = $ (window). width ();
var _adbodycontainerid = "Bigad_" +settings.width;
var _adclosecontainerid = "Bitadclose_" +settings.width;
var closehtml = ' Ad surplus <span id= "__sec" ></span> sec <a href= "javascript:;" id= "__close_ad" > Close </a> " ;
Advertising content Container
var _adcontent = ' <div id= ' +_adbodycontainerid+ ' "></div>";
Close the button container
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)/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:
Copy Code code as follows:
<div id= "Testad" ></div>
<script>
$ (function () {
$ (' #testad '). Quickad ({
HTML: ' });
})
</script>
Okay, OK!