关注前端开发
关注用户体验

js定时显示广告代码

这是一则定时显示广告的javascript代码,当然也可以定时显示某一区块内容,很实用。

代码如下:

function strToDate(str, ext) {
	if (str == null || str == '') return;
	var arys = new Array();
	arys = str.split('-');
	var newDate = new Date(arys[0], arys[1] - 1, arys[2], 9, 0, 0);
	if (ext) {
		newDate = new Date(newDate.getTime() + 1000 * 60 * 60 * 24);
	}
	return newDate;
}
function showit(str, start, end) {
	var date = new Date();
	var start = strToDate(start);
	var end = strToDate(end, false);
	if (date & gt; start & amp; & amp; date document.write(str);
}
}

调取:

showit('Your ads','2011-07-06','2011-07-18');
赞(0)
未经允许不得转载:大前端 » js定时显示广告代码
分享到: 更多 (0)

评论 18

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #14

    I simply found your internet website many days ago and i have been reading through it frequently. you have got a good range of useful data on the site and

    Wayne Schull1周前 (05-17)回复
  2. #13

    i am using infolinks and chitika and i think infolinks have the best payout ..

    Abel Moseby2周前 (05-13)回复
  3. #12

    I do not even know how I finished up right here, however I believed this publish was good. I do not realize who you’re but certainly you are going to a well-known blogger when you are not already Cheers!

    Nonton Anime2周前 (05-10)回复
  4. #11

    Have you considered about introducing some social bookmarking buttons to these blog posts. At least for facebook.

    cat products3周前 (05-09)回复
  5. #10

    there are lots of exercise guides on the internet but some of them are not scientifically proven and just assumptions;;

    my singing monsters2个月前 (03-28)回复
  6. #9

    Enjoyed looking through this, very good stuff, thanks .

    Ronna Lambson3个月前 (03-11)回复
  7. #8

    daanjia.com lanvbo.com

    6862年前 (2017-07-16)回复
  8. #7

    ceshi

    cesss2年前 (2017-05-12)回复
  9. #6

    有问题 😮

    6年前 (2013-01-25)回复
  10. #5

    if (date & gt; start & amp; & amp; date document.write(str);
    }这块是不是有问题啊。应该是转码后的把。

    dingyanqiang7年前 (2012-07-20)回复
  11. #4

    怎么不能下载例子啊

    怡炜8年前 (2011-11-23)回复
  12. #3

    能解释一下 变量 end的作用么? 还有他怎么用

    hzz8年前 (2011-08-05)回复
  13. #2

    很实用,收藏了

    晨光8年前 (2011-07-06)回复
  14. #1

    不错不错 学习了!感谢分享

    yu8年前 (2011-07-06)回复

themebetter 国内更好的WordPress主题服务商

立即前往