Let's just say nothing about it. Go directly to the Code:
Jquery Plugin:
Copy codeThe Code is as follows:
/*
Crazy talent was created on
QQ: 1055818239
Email: hxl_apple@163.com
*/
(Function ($ ){
$. Fn. quickAd = function (settings ){
Settings = $. extend ({
Width: 760,
Height: 400,
Html: 'I am an advertisement content ',
Top: 130,
Sec: 5, // ad display duration, in seconds
Border: true // display the external box
}, Settings );
Var fkxc_ad = 0;
Var bodyWidth = $ (window). width ();
Var _ adBodyContainerID = "bigAd _" + settings. width;
Var _ adCloseContainerID = "bitAdClose _" + settings. width;
Var closeHtml = 'remaining <span id = "_ sec"> </span> seconds <a href = "javascript :; "id =" _ close_ad "> close </a> ';
// Ad content container
Var _ adContent = '<div id = "' + _ adBodyContainerID + '"> </div> ';
// Close the button container
Var _ adCloseBtn = '<div id = "' + _ adCloseContainerID + '">' + closeHtml + '</div> ';
Var self = $ (this );
Certificate (this).empty().html (_ adContent + _ adCloseBtn );
$ ('#__ Close_ad'). click (function (){
Window. clearTimeout (fkxc_ad );
Self. fadeOut ();
})
If (settings. border ){
Certificate ('region_adbodycontainerid).css ('border', '1px solid # ccc ');
}
Certificate ('{'{_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 ');
Certificate ('{'}_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:
Copy codeThe Code is as follows:
<Div id = "testad"> </div>
<Script>
$ (Function (){
$ ('# Testad'). quickAd ({
Html: ''
});
})
</Script>
OK!