Home Web Front-end JS Tutorial Imitation Zhongguancun Online homepage pop-up advertising plug-in (jQuery version)_jquery

Imitation Zhongguancun Online homepage pop-up advertising plug-in (jQuery version)_jquery

May 16, 2016 pm 05:53 PM
Zhongguancun

Not much to say, just go to the code:
jquery plug-in:

Copy code The code is as follows:

/*
Crazy Scholar produced on 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 am an advertisement Content',
top:130,
sec:5, //Ad display duration, unit seconds
border:true //Display outer frame
},settings);
var fkxc_ad = 0;
var bodyWidth = $(window).width();
var _adBodyContainerID = "bigAd_" settings.width;
var _adCloseContainerID = "bitAdClose_" settings.width;
var closeHtml = ' Advertising remaining<span id="__sec"></span> seconds<a href="javascript:;" id="__close_ad">Close</a>';
//Advertising content Container
var _adContent = '<div id="' _adBodyContainerID '"></div>';
//Close 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) / 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 code The code is as follows:

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

Ok!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Replace String Characters in JavaScript Replace String Characters in JavaScript Mar 11, 2025 am 12:07 AM

Replace String Characters in JavaScript

Custom Google Search API Setup Tutorial Custom Google Search API Setup Tutorial Mar 04, 2025 am 01:06 AM

Custom Google Search API Setup Tutorial

Example Colors JSON File Example Colors JSON File Mar 03, 2025 am 12:35 AM

Example Colors JSON File

8 Stunning jQuery Page Layout Plugins 8 Stunning jQuery Page Layout Plugins Mar 06, 2025 am 12:48 AM

8 Stunning jQuery Page Layout Plugins

Build Your Own AJAX Web Applications Build Your Own AJAX Web Applications Mar 09, 2025 am 12:11 AM

Build Your Own AJAX Web Applications

What is 'this' in JavaScript? What is 'this' in JavaScript? Mar 04, 2025 am 01:15 AM

What is 'this' in JavaScript?

Improve Your jQuery Knowledge with the Source Viewer Improve Your jQuery Knowledge with the Source Viewer Mar 05, 2025 am 12:54 AM

Improve Your jQuery Knowledge with the Source Viewer

10 Mobile Cheat Sheets for Mobile Development 10 Mobile Cheat Sheets for Mobile Development Mar 05, 2025 am 12:43 AM

10 Mobile Cheat Sheets for Mobile Development

See all articles