HTML增加页面刷新及其应用例子

刷新一般指重新载入当前页面。本文先给出html页面刷新重载方法汇总,再给出示例。

html页面刷新重载方法汇总

一、javascript页面刷新重载的方法:

<a href="javascript:location.reload();">点击重新载入页面</a>

<a href="javascript:history.go(0);">点击重新载入页面</a>

<a href="javascript:location=location;">点击重新载入页面</a>

<a href="javascript:location=location.href;">点击重新载入页面</a>

<a href="javascript:location.replace(location);">点击重新载入页面</a>

<a href="javascript:location.replace(location.href);">点击重新载入页面</a>

<a href="javascript:location.assign(location);">点击重新载入页面</a>

<a href="javascript:location.assign(location.href);">点击重新载入页面</a>

<!--// 以下只支持ie -->

<a href="javascript:document.URL=location.href;">点击重新载入页面</a>

<a href="javascript:navigate(location);">点击重新载入页面</a>

<a href="javascript:document.execCommand('Refresh');">点击重新载入页面</a>

使用按钮的方式如下

<script>

  function reloadPage(){

      window.location.reload();

  }

</script>

<input type="button" value="重新加载页面" οnclick="reloadPage()" />

二、html链接重新载入方法

<a href="">点击重新载入页面</a>

<a href="页面本身">点击重新载入页面</a>

三、实现html页面自动刷新

1. 页面自动刷新:

<meta http-equiv="refresh" content="10">

 注:content="10"其中的数字表示刷新间隔的秒数

2.跳转到指定页面:

<meta http-equiv="refresh" content="10;url=你的网站地址如www.smddw.com">

 3.页面自动刷新js版:

<script language="JavaScript">script">

   setTimeout(function(){location.reload()},1000); //指定1秒刷新一次

</script>
示例

例1、先给出一个简单的示例效果

点击网页上的按钮或链接,显示的时间的变化了——因为页面刷新了,相当页面重新打开了。
posted @ 2024-07-02 16:54  webcc  阅读(5)  评论(0编辑  收藏  举报