依赖jquery和jquery.cookie的弹窗广告代码

作者: zms! 日期: 2019.05.07 本文发布于219天前 分类: jquery 相关:

可定义时间周期弹一次,如一日限弹一次,简洁好用,自带样式

广告代码:

function cGlobalAd(div){$(div).hide()}function zGlobalAd(zImg,zUrl,zW,zH,zCOOKIE,zExp){if(zCOOKIE&&!$.cookie(zCOOKIE)){var zHH=zH+50,ZHH=$(window).height(),ZWW=$(window).width();$("head").append("<style>.zover{width:100%;height:100%;position:fixed;top:0;left:0;filter:alpha(opacity=50);opacity:0.5;background:#000;z-index:999997;}#globalAd{width:"+zW+"px;height:"+zHH+"px;position:fixed;;margin:0 auto;z-index:999998;text-align:center;}.globalContent{width:"+zW+"px;height:"+zH+"px}.globalContent img{max-width:"+zW+"px;max-height:"+zH+"px;}.closeIco{width:100%;height:38px;margin-top:12px;cursor:pointer;}</style>");$("body").append("<div class=\"zover\"></div><div id=\"globalAd\"><a href=\""+zUrl+"\" target=\"_blank\" class=\"globalContent\" onclick=\"cGlobalAd('#globalAd,.zover');\"><img src=\""+zImg+"\"/></a><div onclick=\"cGlobalAd('#globalAd,.zover');\" class=\"closeIco\"><img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAMAAACf4xmcAAAAA3NCSVQICAjb4U/gAAAARVBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD////z8/Pm5ubV1dVSUlJKSkpDQ0MGBgYAAAA+LLbmAAAAF3RSTlMAESIzVWZ3iJmqu8zd7v///////////9JmQR4AAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAfdEVYdFNvZnR3YXJlAE1hY3JvbWVkaWEgRmlyZXdvcmtzIDi1aNJ4AAAA+ElEQVQ4jZXU6xqEEBAGYNnQAZ3n/i91SbVG1Oz3S7vvQyOGMRQuWw2gW8lZMZXwJkS3osojZQDFqAwUCdqnrFPV3JFPgxfs8gqgjVlRIVdYMUSdqn5SAEcdVabGODrsi3pWABJPtk7Tco6XaVrPsfHTifNpG621cxjPbjhu8dt1iAXnVcTcpnx+BSz2cLuy1wv4IuICjr8vfkWwHm7uptyquPY5q6BPGKyDR8OKfzU0Bkyjx8KiGp+hUgkdkzeV2RDJuE5Ubns59WNRPr2gH6T3Y6lIh9xU/1wZ6gWkXucHhxSx1ZAbF7UNeii696a6h0snjTNJi/4CtZ5XP2CpVBgAAAAASUVORK5CYII=\" width=\"38\" height=\"38\" /></div></div>");$("#globalAd").css({'top':ZHH/2-$("#globalAd").height()/2,'left':ZWW/2-$("#globalAd").width()/2});$.cookie(zCOOKIE,1,{path:'/',expires:zExp})}}

调用方式:

zGlobalAd('http://wx.ehgo.com/static/img/global/vip.png','http://ehgo.cn',337,418,'Z2B35C74BD368A390',1);    //图片,网址,图片宽度,图片高度,COOKIE名,时间周期(天)


返回上一页


讨论区

您尚未 登录,或请 注册

登 录 注 册


你可能也喜欢

依赖jquery和jquery.cookie的弹窗广告代码 2019.05.07,19 pv
jQuery的选择器中的通配符及jquery选择器总结, 2018.04.29,4 pv
jquery-timeago 方便实用的时间戳自动更新库 2017.05.30,1 pv