转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 站长学院 >> Web开发 >> 正文
JavaScript实现自动刷新页面         ★★★★

JavaScript实现自动刷新页面

作者:闵涛 文章来源:闵涛的学习笔记 点击数:614 更新时间:2009/4/23 11:23:01

  今天访问了硅谷动力网络学院,发现其中下部有一行图片经过指定时间变化一次,实现图片文章的显示,觉得效果不错,打开查看了一下源代码,发现其使用的是刷新的功能,在这里给大家说说。具体代码为:

<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>    &nbsp;&nbsp;    <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>    &nbsp;&nbsp;    <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>    &nbsp;&nbsp;    <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>    &nbsp;&nbsp;    <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>    &nbsp;&nbsp;    <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>    &nbsp;&nbsp;    <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>    &nbsp;&nbsp;    <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>    &nbsp;&nbsp;    <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>    &nbsp;&nbsp;    <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>    &nbsp;&nbsp;    <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>    &nbsp;&nbsp;    <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>    &nbsp;&nbsp;    <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实际显示的页面


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · Web开发  · 网页制作
    · 平面设计  · 网站运营
    · 网站推广  · 搜索优化
    · 建站心得  · 站长故事
    · 互联动态
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台