jquery实现滑屏大图定时收缩为小banner图片的广告

这是一款基于jQuery实现的JS广告特效,滑屏大图广告定时收缩为小banner图片广告代码,这种广告在各大门户网站现在还能看得到,刚打开网页的时候可以看到滑下来的大图片广告,过一会,广告自动缩小变成了一个banner横幅广告,并带有关闭按钮,可以关闭广告,对于广告来说,这个代码挺实用。

运行效果截图如下:

jquery实现滑屏大图定时收缩为小banner图片的广告

在线演示地址如下:

具体代码如下:

<!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>jQuery顶部大图定时缩为小广告可关闭代码</title> <style> body{ margin:0; padding:0;} img{ border:0} .root1200{ width:1200px; height:100px; margin:0 auto; overflow:visible} .wrapper em{ width:40px; height:15px; float:left; color:#FFF; font-size:12px; font-family:Verdana, Geneva, sans-serif;background:#333; margin:0 0 -20px 10px; padding:2px 5px 2px 10px; z-index:999; position:absolute; top:10px;} </style> <script language="javascript" src="https://www.jb51.net/jquery-1.6.2.min.js"></script> </head> <body> <script type="text/javascript"> /* * 宽窄屏切换 * */ var bigscreen = false; if ( screen.width>=1200 ) { bigscreen = true; var bodyTag = document.getElementsByTagName("body")[0], bodyClassName = bodyTag.getAttribute("className") || bodyTag.getAttribute("class"); bodyClassName = bodyClassName ? bodyClassName+" " : ""; bodyTag.className = bodyClassName+"root1200"; } </script> <div> <em title="关闭广告">Close</em> <a target="_blank" title="小图" href="https://www.jb51.net/"></a> <a target="_blank" title="大图" href="https://www.jb51.net/"></a> </div> <script type="text/javascript"> ~function (){ var snActive = window.snActive = document.getElementById("snActive-wrap"), a = snActive.getElementsByTagName("a"), h = 0, w, imgSrc = []; if (bigscreen){ w = 1190; imgSrc[0] = "images/1390124030537_1200.jpg";// 40 imgSrc[1] = "images/1390124049068_1200.jpg";// 500 } else { w = 990; imgSrc[0] = "images/1390124028186.jpg";// 40 imgSrc[1] = "images/1390124043025.jpg";// 500 } snActive.style.overflow = 'hidden'; a[0].style.display = "none"; a[0].innerHTML += '<img src="' + imgSrc[0] + '" />'; if(a[1]){ a[1].innerHTML += '<img src="' + imgSrc[1] + '" />'; } }(); //关闭通栏广告 var snActive = $(snActive), hideImg = snActive.find('a:hidden'), em = snActive.find("em"); timeout = !1; if(hideImg[0]) { timeout = setTimeout(function(){ snActive.animate({height:40},600,function(){ hideImg.siblings('a:visible').hide(); hideImg.show(); em.show().live("click",function(){ snActive.slideUp(300); }); }); }, 3000) } </script> <div> </div> </body> </html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wggdgx.html