Imitation Zhongguancun homepage Pop-up advertising plugin (jquery version) _jquery

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.