今天访问了硅谷动力网络学院,发现其中下部有一行图片经过指定时间变化一次,实现图片文章的显示,觉得效果不错,打开查看了一下源代码,发现其使用的是刷新的功能,在这里给大家说说。具体代码为:
<table width="748" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height=95 background="ab28-1.gif" width="23" > </td>
<td height=95 align="center" background="ab28-2.gif">
<a href="http://www.enet.com.cn/eschool/inforcenter/A20040410301390.html" target="_blank"><img src="/eschool/images/v2/main1.gif" vspace=8 border=0 class=border_img></a> <a href="http://www.enet.com.cn/eschool/inforcenter/A20040819335401.html" target="_blank"><img src="/eschool/images/v2/baishi.gif" vspace=8 border=0 class=border_img></a> <a href="http://www.enet.com.cn/edu/inforcenter/A20041015352615.html" target="_blank"><img src="/eschool/images/v2/5jianwanfu.gif" vspace=8 border=0 class=border_img></a> <a href="http://www.enet.com.cn/eschool/inforcenter/A20041009350269.html" target="_blank"><img src="/eschool/images/v2/PHOTOSHOPtianse.gif" vspace=8 border=0 class=border_img></a> <a href="http://www.enet.com.cn/eschool/inforcenter/A20050415408861.html" target="_blank"><img src="/eschool/images/v2/54764567.gif" vspace=8 border=0 class=border_img></a> </td>
<td height=95 background="ab28-3.gif" width="16"></td>
</tr>
</table>
<script>setTimeout("location.href='rdztt2.html'",10000);</script>
把上面的代码保存为一个文件为rdztt1.html,然后我们再建立了一个文件rdztt2.html,内容如下:
<table width="748" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height=95 background="ab28-1.gif" width="23" > </td>
<td height=95 align="center" background="ab28-2.gif">
<a href="http://www.enet.com.cn/eschool/inforcenter/A20040825337317.html" target="_blank"><img src="/eschool/images/v2/yingpan.gif" vspace=8 border=0 class=border_img></a> <a href="http://www.enet.com.cn/eschool/inforcenter/A20041109360306.html" target="_blank"><img src="/eschool/images/v2/9mmnbvc.gif" vspace=8 border=0 class=border_img></a> <a href="http://www.enet.com.cn/eschool/zhuanti/iis/" target="_blank"><img src="/eschool/images/v2/iisserver.gif" vspace=8 border=0 class=border_img></a> <a href="http://www.enet.com.cn/edu/inforcenter/A20040811332742.html" target="_blank"><img src="/eschool/images/v2/nianxin.gif" vspace=8 border=0 class=border_img></a> <a href="http://www.enet.com.cn/eschool/inforcenter/A20040816334318.html" target="_blank"><img src="/eschool/images/v2/psxuejing.gif" vspace=8 border=0 class=border_img></a> </td>
<td height=95 background="ab28-3.gif" width="16"></td>
</tr>
</table>
<script>setTimeout("location.href='rdztt3.html'",10000);</script>
然后又建立了一个rdztt3.html,内容如下:
<table width="748" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height=95 background="ab28-1.gif" width="23" > </td>
<td height=95 align="center" background="ab28-2.gif">
<a href="http://www.enet.com.cn/eschool/zhuanti/fireworks/" target="_blank"><img src="/eschool/images/v2/fireworkview.gif" vspace=8 border=0 class=border_img></a> <a href="http://www.enet.com.cn/eschool/inforcenter/A20041022355087.html" target="_blank"><img src="/eschool/images/v2/6uryeyu.gif" vspace=8 border=0 class=border_img></a> <a href="http://www.enet.com.cn/eschool/inforcenter/A20050118383106.html" target="_blank"><img src="/eschool/images/v2/tuijianjingmei5.jpg" vspace=8 border=0 class=border_img></a> <a href="http://www.enet.com.cn/eschool/inforcenter/A20050119383530.html" target="_blank"><img src="/eschool/images/v2/xiugaiwinxpzhi7.jpg" vspace=8 border=0 class=border_img></a> <a href="http://www.enet.com.cn/eschool/inforcenter/A20050119383752.html" target="_blank"><img src="/eschool/images/v2/jinchdenggua8.jpg" vspace=8 border=0 class=border_img></a> </td>
<td height=95 background="ab28-3.gif" width="16"></td>
</tr>
</table>
<script>setTimeout("location.href='rdztt1.html'",10000);</script>
大家可以注意到上面三个文件中均有如下代码:
<script>setTimeout("location.href='*****.html'",10000);</script>
这就是实现自动刷新的代码,使用了setTimeout()函数设置为每隔10秒钟刷新一次!最后使用iframe标签加到主页中:
<iframe name="titleframe" src='/eschool/includes/gdtup/tu5/rdztt1.html' noresize="Yes" scrolling="No" frameborder="0" marginheight="0" marginwidth="0" width=750 height=100></iframe>
具体演示效果大家可以看看
http://www.enet.com.cn/eschool/中下部变化的图片
http://www.enet.com.cn/eschool/includes/gdtup/tu5/rdztt1.html实际显示的页面