一般广告位的实现都是一个独立的模块,哪里需要添加广告位,就把这个广告位插在哪里;而这个广告位通常都是由一个 js 链接导入的。 在这段广告位的 js 代码里,主要的功能点有: 以下放出代码,大家可进行参考,欢迎批评建议:
jumeiForU.init({
start: '2015/02/01 00:00',
end: '2016/01/01 00:00',
width: 400,
height: 400,
});
<script type="text/javascript" src="http://xxx.js?referer=wenzi">script>
(function () {
var jumeiForU = {
// 初始化
init: function (_config) {
this.config = this.extend(this.config, _config);
this.show();
},
// 广告展示及跳转链接
data: [
{
title: '九朵云祛斑霜',
img: 'http://p0.jmstatic.com/g/300x250/ht150122p854446t1.jpg',
url: 'http://www.jumeiglobal.com/deal/ht150122p854446t1.html?referer=',
},
{
title: 'Guerisson奇迹马油24K金面膜贴',
img: 'http://p0.jmstatic.com/g/300x250/ht150122p1293256t1.jpg',
url: 'http://www.jumeiglobal.com/deal/ht150122p1293256t1.html?referer=',
},
{
title: 'Its-skin晶钻蜗牛面膜',
img: 'http://p0.jmstatic.com/g/300x250/ht150122p818496t1.jpg',
url: 'http://www.jumeiglobal.com/deal/ht150122p818636t1.html?referer=',
},
{
title: '九朵云美白祛斑气垫BB霜',
img: 'http://p0.jmstatic.com/g/300x250/ht150122p1293254t1.jpg',
url: 'http://www.jumeiglobal.com/deal/ht150122p1293254t1.html?referer=',
},
{
title: '可莱丝NMF水库针剂睡眠面膜5片',
img: 'http://p0.jmstatic.com/g/300x250/ht150122p1312153t1.jpg',
url: 'http://www.jumeiglobal.com/deal/ht150122p1312153t1.html?referer=',
},
{
title: '猪皮面膜',
img: 'http://p0.jmstatic.com/g/300x250/ht150122p1254465t1.jpg',
url: 'http://www.jumeiglobal.com/deal/ht150122p1254465t1.html?referer=',
},
{
title: '奇迹马油精华套装',
img: 'http://p0.jmstatic.com/g/300x250/ht150122p1293257t1.jpg',
url: 'http://www.jumeiglobal.com/deal/ht150122p1293257t1.html?referer=',
},
{
title: '九朵云美白祛斑套组',
img: 'http://p0.jmstatic.com/g/300x250/ht150122p1293255t1.jpg',
url:
'http://www.jumeiglobal.com/deal/ht150122p1293255t1.html?referer=',
},
{
title: '晶钻蜗牛修护睡眠面膜',
img: 'http://p0.jmstatic.com/g/300x250/ht150122p818636t1.jpg',
url: 'http://www.jumeiglobal.com/deal/ht150122p818496t1.html?referer=',
},
{
title: 'skin1004僵尸面膜',
img: 'http://p0.jmstatic.com/g/300x250/ht150122p1265333t1.jpg',
url: 'http://www.jumeiglobal.com/deal/ht150122p1265333t1.html?referer=',
},
],
// 配置
config: {
start: '2015/01/01 00:00',
end: '2030/01/01 00:00',
width: 300,
height: 250,
},
// 广告展示
show: function () {
var nowtime = new Date().getTime(),
starttime = new Date(this.config.start).getTime(),
endtime = new Date(this.config.end).getTime(),
random = this.getRandom(),
referer = this.getCurrentScript('referer');
if (nowtime >= starttime && nowtime < endtime) {
document.write(
'
版权属于:
加速器之家
作品采用:
《
署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
》许可协议授权
评论