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=你的网站地址">

3.页面自动刷新js版:

<script language="JavaScript">script">

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

</script>

示例

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

点击网页上的按钮或链接,显示的时间的变化了——因为页面刷新了,相当页面重新打开了。

HTML页面重载,源码如下:

<html>
<head>
<meta charset="UTF-8">
<title>html页面刷新重载</title><script>function  getD1(){var date=new Date();var d1=date.toLocaleString(); document.getElementById("times").innerHTML =d1; }function reloadPage(){window.location.reload();}
</script>
</head>
<body  onload = getD1()>
<input type="button" value="重新加载页面" onclick="reloadPage()" />
<br/>
<a href="javascript:location.reload();">点击重新载入页面</a>
<br/>
<a href="">点击重新载入页面</a>
<br/>
<a href="html页面刷新重载示例.html">点击重新载入页面</a>
<br/>
<br/>
当前时间:
<div id="times">/div></body>
</html>

例2、下面再给出一个例子(仅使用了按钮的方式)

先看效果

源码如下:

<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>文字烟雾效果</title><style>*{margin: 0;padding: 0;box-sizing: border-box;}div{height: 100vh;display: flex;justify-content: center;align-items: center;background-color: rgb(0, 0, 0);overflow: hidden;}.text{position: relative;width: 500px;text-indent: 2em;color: rgb(255, 255, 255);font-size: 28px;cursor: pointer;user-select: none;text-align: justify;           }.text span{position: relative;display: inline-block;transform-origin: bottom;text-indent: 0;}.text .move{        animation: up 2s linear forwards;}@keyframes up{100%{opacity: 0;filter: blur(20px);transform: translate(600px,-500px) rotate(360deg) scale(5);}}</style>
</head>
<body>
<input type="button" value="重新加载页面" onclick="reloadPage()" >
<p> 移动鼠标滑过下面的文字</p>
<div>
<p class="text">往事如烟&nbsp;&nbsp;总是在太迟了的时候&nbsp;&nbsp;
才会珍惜&nbsp;&nbsp;那一种无奈的感悟&nbsp;&nbsp;总是在孤独的路途上&nbsp;&nbsp;
才会纪念&nbsp;&nbsp;有段一去不复返的岁月 </p>
<div><script>var txt = document.querySelector(".text");txt.innerHTML = txt.textContent.replace(/\S/g,"<span>$&</span>");var arr = document.querySelectorAll("span");arr.forEach(function(temp){temp.addEventListener('mouseover',()=>{temp.classList.add('move');console.log('666');})}) //重载页面function reloadPage() {window.location.reload();}    </script>
</body>
</html>

OK!

HTML页面刷新及其应用例子相关推荐

  1. 按下enter键禁止页面刷新

    这里讲解一下,PC端,前端可以遇到的一个问题,就是按下enter键禁止页面刷新. 这里有一个例子: 这个是我开发的一个项目.在这里面,我们在右上角搜索里面输入图片名字,按下搜索按钮就会检索出对应的图片 ...

  2. java局部刷新session过期_Ajax局部页面刷新和History API结合的陷阱

    ajax在现代网站已经得到非常普遍地应用,主要的好处大家都知道(异步加载数据,不用刷新整个浏览器,更小的数据传输尺寸).对于那些老网站或者老项目来说全盘改造成ajax并不现实,于是就有了"局 ...

  3. VUE监听页面刷新和关闭事件

    背景:公司有一个数据看板,,需求是要统计看板有多少人看过,,每个人停留的曝光时间 使用技术:目前使用的技术是 后端Springboot 权限用的是SpringSecurity,前端页面是 Vue+El ...

  4. 网站输入正确账号密码页面刷新一下_淘宝开店卖家如何正确发布宝贝?先学会这3个技巧,不要再迷茫了...

    >>阅读前,请点击右上角[关注]口袋电商课,让你少走一年弯路! 当自己店铺的产品较少,发布宝贝显得很简单.但当自己的店铺单品很多时,这项工作就显得繁琐,光是产品的主图和详情页就够让人头大, ...

  5. php js页面刷新,JavaScript刷新页面location.reload()的用法

    在我们日常工作中,在进行JavaScript编辑过程中,很多时候都需要使用JS刷新页面的功能,所以我们会经常用到location.reload(),今天我们就大家了解下JavaScript刷新页面lo ...

  6. js 弹出一个页面 html页面刷新,原生js刷新当前页面与跳转页面的几种方法及区别总结...

    在面向浏览器的web开发过程中,我们经常与JavaScript打交道,web开发页面路由跳转.刷新当前页面更是经常遇到的事.浏览器提供了至少3-5种的方式可以实现当前页面刷新或者跳转当前应用的其他页面 ...

  7. element 的 el-form (禁止页面刷新与from验证 vue3)

    一.在添加el-from后点击会导致整个页面刷新,在vue3中可以如下避免: <el-formref="submitFormRef":model="createFo ...

  8. php页面刷新$_session会变化,每次刷新页面都会生产新的session_id

    在测试通过 URL 来传递 session_id 的时候,发现没进行一次页面刷新,都会生成一个新的 session_id,有没有办法重用现有的 session_id ? 代码: set_session ...

  9. java 判断页面刷新_如何判断一个网页是刷新还是关闭的方法

    页面加载时只执行onload 页面关闭时只执行onunload 页面刷新时先执行onbeforeunload,然后onunload,最后onload.这样我们可以在onbeforeunload中加一个 ...

最新文章

  1. 丘维声高等代数pdf_2020年兰州大学高等代数真题出处简直惊讶
  2. 某程序员吐槽清华北大不值钱了!过去清北毕业生去企业上班就是丢人现眼!现在互联网基层员工一堆清北人!清北怎么混成这样了?...
  3. 与servlet Api 的集成
  4. java取geosever数据_Geoserver - 连接到SQL Server 2008 Express并获取数据
  5. js模拟栈---进制转化。十进制转任意进制进制,任意进制转十进制
  6. 人工智能AI-机器视觉CV-数据挖掘DM-机器学习ML-神经网络-[资料集合贴]
  7. 8Cocos Creator组件开发cc.Component
  8. Codeforces Round #723 (Div. 2) D. Kill Anton 线段树 + 暴力
  9. 创建win32 dll
  10. 关于NFS服务器的原理总结和mount挂载
  11. java文件下载至linux乱码,JAVA 文件下载乱码问题解决办法
  12. Tensorflow 2.0 打印 Tensor
  13. 初识lunece(同义词检索)
  14. Spring整合Struts2,Hibernate的xml方式
  15. mysqld mysql-debug_mysqld --debug-sync
  16. VNCTF2021[WEB]
  17. QT常用控件——QLabel标签控件
  18. 路由器的两个端口接在同一个交换机上_交换机到底有什么用啊?
  19. 1.U3D和U3D安装介绍
  20. 力扣刷题 DAY_74 回溯

热门文章

  1. 【工具类】钉钉群机器人告警-解决限流
  2. openpyxl模块安装及使用
  3. MySQL增加字段,修改字段,增加索引等语句
  4. 从0.1开始学Python——[6]
  5. 使用 EasyExcel 读取Excel 解析复杂表格
  6. 使用JavaScript实现10秒倒计时
  7. C语言蓝牙协议栈讲解,蓝牙协议栈记录—BTStack
  8. android微信支付黑屏,Android 調用微信登陸、支付、分享,出現的白屏、黑屏、閃屏問題。...
  9. mysql之group_concat函数详解
  10. 启动rrt什么意思_rrt