基于jQuery的仿flash的廣告輪播
更新時(shí)間:2010年11月05日 22:39:14 作者:
很多網(wǎng)站的首頁(yè)都有廣告輪播,今天閑來(lái)看了一網(wǎng)站的首頁(yè)廣告輪播方式,是通過(guò) jQuery的blockSlide插件實(shí)現(xiàn)的,然后自己測(cè)試了一下,很好。
整個(gè)頁(yè)面如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script src="_Template/js/blockSlide.js" type="text/javascript"></script>
<style type="text/css">
div#imgADPlayer
{
margin: auto;
margin-bottom: 4px;
width: 960px;
height: 120px;
background: url(../images/photo_01.jpg) left top no-repeat;
padding: 0px;
border: none;
clear: both;
position: relative;
}
div#imgADPlayer .smask
{
position: absolute;
left: 0px;
top: 0px;
}
</style>
</head>
<body>
<!-- 滾動(dòng)圖片開(kāi)始 -->
<div id="imgADPlayer">
<div id="AdTop">
<div id="myjQueryContent">
<div>
<a href="javascript:void(0)">
<img src="_Template/images/photo_01.jpg" alt="" /></a></div>
<div class="smask">
<a href="javascript:void(0)">
<img src="_Template/images/photo_02.jpg" alt="" /></a></div>
<div class="smask">
<a href="javascript:void(0)">
<img src="_Template/images/photo_03.jpg" alt="" /></a>
</div>
<div class="smask">
<a href="javascript:void(0)">
<img src="_Template/images/photo_04.jpg" alt="" /></a></div>
</div>
<div id="flow">
</div>
</div>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$("#AdTop").blockSlide({
speed: "normal",
num: 4,
timer: 3000,
flowSpeed: 300
});
});
</script>
</div>
<!--滾動(dòng)圖片結(jié)束 -->
</body>
</html>
注釋:
speed:圖片輪播速度
num:圖片數(shù)量
timer:自動(dòng)輪播的時(shí)間間隔,定時(shí)器;
flowSpeed:是滑塊移動(dòng)的速速度
blockSlide插件源碼如下:
/**
* @author huajianhuakai */
(function($)
{
$.fn.blockSlide = function(settings)
{
settings = jQuery.extend({
speed: "normal",
num: 4,
timer: 1000,
flowSpeed: 300
}, settings);
return this.each(function()
{
$.fn.blockSlide.scllor($(this), settings);
});
};
$.fn.blockSlide.scllor = function($this, settings)
{
var index = 0;
var imgScllor = $("div:eq(0)>div", $this);
var timerID;
//自動(dòng)播放
var MyTime = setInterval(function()
{
ShowjQueryFlash(index);
index++;
if (index == settings.num)
index = 0;
}, settings.timer);
var ShowjQueryFlash = function(i)
{
$(imgScllor).eq(i).animate({ opacity: 1 }, settings.speed).css({ "z-index": "100" }).siblings().animate({ opacity: 0 }, settings.speed).css({ "z-index": "0" });
}
}
})(jQuery);
希望對(duì)和我一樣的菜鳥(niǎo)有用
復(fù)制代碼 代碼如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script src="_Template/js/blockSlide.js" type="text/javascript"></script>
<style type="text/css">
div#imgADPlayer
{
margin: auto;
margin-bottom: 4px;
width: 960px;
height: 120px;
background: url(../images/photo_01.jpg) left top no-repeat;
padding: 0px;
border: none;
clear: both;
position: relative;
}
div#imgADPlayer .smask
{
position: absolute;
left: 0px;
top: 0px;
}
</style>
</head>
<body>
<!-- 滾動(dòng)圖片開(kāi)始 -->
<div id="imgADPlayer">
<div id="AdTop">
<div id="myjQueryContent">
<div>
<a href="javascript:void(0)">
<img src="_Template/images/photo_01.jpg" alt="" /></a></div>
<div class="smask">
<a href="javascript:void(0)">
<img src="_Template/images/photo_02.jpg" alt="" /></a></div>
<div class="smask">
<a href="javascript:void(0)">
<img src="_Template/images/photo_03.jpg" alt="" /></a>
</div>
<div class="smask">
<a href="javascript:void(0)">
<img src="_Template/images/photo_04.jpg" alt="" /></a></div>
</div>
<div id="flow">
</div>
</div>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$("#AdTop").blockSlide({
speed: "normal",
num: 4,
timer: 3000,
flowSpeed: 300
});
});
</script>
</div>
<!--滾動(dòng)圖片結(jié)束 -->
</body>
</html>
注釋:
speed:圖片輪播速度
num:圖片數(shù)量
timer:自動(dòng)輪播的時(shí)間間隔,定時(shí)器;
flowSpeed:是滑塊移動(dòng)的速速度
blockSlide插件源碼如下:
復(fù)制代碼 代碼如下:
/**
* @author huajianhuakai */
(function($)
{
$.fn.blockSlide = function(settings)
{
settings = jQuery.extend({
speed: "normal",
num: 4,
timer: 1000,
flowSpeed: 300
}, settings);
return this.each(function()
{
$.fn.blockSlide.scllor($(this), settings);
});
};
$.fn.blockSlide.scllor = function($this, settings)
{
var index = 0;
var imgScllor = $("div:eq(0)>div", $this);
var timerID;
//自動(dòng)播放
var MyTime = setInterval(function()
{
ShowjQueryFlash(index);
index++;
if (index == settings.num)
index = 0;
}, settings.timer);
var ShowjQueryFlash = function(i)
{
$(imgScllor).eq(i).animate({ opacity: 1 }, settings.speed).css({ "z-index": "100" }).siblings().animate({ opacity: 0 }, settings.speed).css({ "z-index": "0" });
}
}
})(jQuery);
希望對(duì)和我一樣的菜鳥(niǎo)有用
您可能感興趣的文章:
- jQuery實(shí)現(xiàn)Flash效果上下翻動(dòng)的中英文導(dǎo)航菜單代碼
- jQuery仿Flash上下翻動(dòng)的中英文導(dǎo)航菜單實(shí)例
- 超炫的jquery仿flash導(dǎo)航欄特效
- 基于jquery1.4.2的仿flash超炫焦點(diǎn)圖播放效果
- 基于jQuery的仿flash的廣告輪播代碼
- 基于Jquery的仿照f(shuō)lash放大圖片效果代碼
- jQuery實(shí)現(xiàn)的類flash菜單效果代碼
- jquery實(shí)現(xiàn)仿Flash的橫向滑動(dòng)菜單效果代碼
- jquery+easeing實(shí)現(xiàn)仿flash的載入動(dòng)畫(huà)
- flash+jQuery實(shí)現(xiàn)可關(guān)閉及重復(fù)播放的壓頂廣告
- php+flash+jQuery多圖片上傳源碼分享
- jQuery模擬完美實(shí)現(xiàn)經(jīng)典FLASH導(dǎo)航動(dòng)畫(huà)效果【附demo源碼下載】
相關(guān)文章
jQuery/$ is not defined報(bào)錯(cuò)的幾種解決方法
jQuery最常見(jiàn)的錯(cuò)誤之一是$ is not defined錯(cuò)誤,本文主要介紹了jQuery/$ is not defined報(bào)錯(cuò)的幾種解決方法,具有一定的參考價(jià)值,感興趣的可以了解一下2024-02-02
jquery動(dòng)態(tài)添加以及遍歷option并獲取特定樣式名稱的option方法
下面小編就為大家分享一篇jquery動(dòng)態(tài)添加以及遍歷option并獲取特定樣式名稱的option方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-01-01
JQuery表格拖動(dòng)調(diào)整列寬效果(自己動(dòng)手寫(xiě)的)
當(dāng)鼠標(biāo)停留在表頭邊框線上時(shí),鼠標(biāo)會(huì)變成表示左右拖動(dòng)的形狀,接著拖動(dòng)鼠標(biāo),會(huì)在表格中出現(xiàn)一條隨鼠標(biāo)移動(dòng)的豎線,最后放開(kāi)鼠標(biāo),表格列寬會(huì)被調(diào)整2014-09-09
jquery css 設(shè)置table的奇偶行背景色示例
jquery css 設(shè)置table的奇偶行背景色2014-06-06
jQuery插件select2利用ajax高效查詢大數(shù)據(jù)列表(可搜索、可分頁(yè))
select2是一款jQuery插件,是普通form表單select組件的升級(jí)版。 接下來(lái)通過(guò)本文給大家介紹jQuery插件select2利用ajax高效查詢大數(shù)據(jù)列表(可搜索、可分頁(yè)),需要的的朋友參考下吧2017-05-05
Jquery實(shí)現(xiàn)簡(jiǎn)單的輪播效果(代碼管用)
這篇文章主要介紹了Jquery實(shí)現(xiàn)簡(jiǎn)單的輪播效果(代碼管用) 的相關(guān)資料,需要的朋友可以參考下2016-03-03
jquery實(shí)現(xiàn)回車鍵觸發(fā)事件(實(shí)例講解)
下面小編就為大家分享一篇jquery實(shí)現(xiàn)回車鍵觸發(fā)事件的實(shí)例講解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2017-11-11

