国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JS實現先顯示大圖后自動收起顯示小圖的廣告代碼

2019-11-20 11:36:56
字體:
來源:轉載
供稿:網友

本文實例講述了JS實現先顯示大圖后自動收起顯示小圖的廣告代碼。分享給大家供大家參考。具體如下:

這是一個非常不錯的JavaScript圖片特效,當最初打開網頁的時候,顯示的是大圖片,就像遮屏廣告一樣,停留一會后,自動緩慢收起,這時由JS控制更換廣告圖片,始終顯示在網頁頂部,在一些大門戶網站我們經常見到這種效果,個人感覺挺酷哦!

先來看看運行效果截圖:

在線演示地址如下:

http://demo.VeVB.COm/js/2015/js-big-to-small-pic-adv-codes/

具體代碼如下:

<!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><title>先顯示大圖隨后自動收起顯示小圖的JS廣告</title><meta http-equiv="content-type" content="text/html;charset=gb2312"><style type="text/css">html,body{margin:0;text-align:center;font-size:12px;}img{border:none}p{margin:0px}</style><script type="text/javascript">var showAD = {curve: function(t, b, c, d, s) {if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;return c / 2 * ((t -= 2) * t * t + 2) + b},fx: function(from, to, playTime, onEnd) {var Me = this,who = this.adWrap,position = 0,changeVal = to - from,curve = this.curve;playTime = playTime / 10;who.style.overflow = 'hidden';function _run() {if (position++<playTime) {who.style.height = Math.max(1, Math.abs(Math.ceil(curve(position, from, changeVal, playTime)))) + "px";setTimeout(_run, 10)} else {onEnd && onEnd.call(Me, to)}};_run()},init: function(info) {var Me = this,loadImg = new Image;loadImg.src = info.endImgURL;window.onload=function() {Me.endImgURL = info.endImgURL;Me.img = document.getElementById(info.imgID);Me.adWrap = document.getElementById(info.adWrapID);var max = Me.img.height;setTimeout(function() {Me.fx(max, 0, 500,function(x) {this.img.src = this.endImgURL;this.curve = function(t, b, c, d) {if ((t /= d) < (1 / 2.75)) {return c * (7.5625 * t * t) + b} else if (t < (2 / 2.75)) {return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b} else if (t < (2.5 / 2.75)) {return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b} else {return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b}};this.fx(0, this.img.height,600)})},info.timeout || 1000)};}};showAD.init({adWrapID: 'ad_box_2009_06',imgID: 'adImg',endImgURL: 'images/as.jpg'});</script></head><body><div id="ad_box_2009_06"><img src="images/ab.jpg" id="adImg"></div></body></html>

希望本文所述對大家的javascript程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 济阳县| 信阳市| 泸水县| 淮安市| 呼和浩特市| 衡阳县| 宁城县| 宣武区| 凭祥市| 绵阳市| 邳州市| 沙河市| 登封市| 卓尼县| 包头市| 枞阳县| 新龙县| 普安县| 剑川县| 遂宁市| 峡江县| 乡宁县| 平阳县| 闽清县| 遂川县| 格尔木市| 阳高县| 甘德县| 闸北区| 师宗县| 聊城市| 洛隆县| 依兰县| 庆安县| 光泽县| 墨竹工卡县| 武威市| 民权县| 庆安县| 特克斯县| 灵寿县|