当前位置:编程学习 > JS >>

图片自动更新(说明)

答案:这是个“懒人”用的办法,你没有时间更新主页,却又不能让三个月前的更新还标着"new",那么用这个js可以帮你的大忙!
这个图片将在2000年1月1日自动消失。
copy下面的代码到你的html文件的<body>和</body>之间:
复制代码 代码如下:

<script>
<!--
var imagetag='<img src="news.gif" alt="1">' var today=new Date() function expireat(expiredate){ var expire=new Date(expiredate) if (today.getTime()<=expire.getTime()) document.write(imagetag) }
//-->
</script>
<script>
expireat("january 1, 2000")
</script>

上一个:DOM精简教程
下一个:浅谈JavaScript中面向对象技术的模拟

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,