刷新页面的几种方法小结(JS,ASP.NET)
时间:2024-05-28 15:37:33
Javascript刷新页面的几种方法:
1. history.go(0)
2. location.reload()
3. location=location
4. location.assign(location)
5. document.execCommand('Refresh')
6. window.navigate(location)
7. location.replace(location)
8. document.URL=location.href
自动刷新页面的方法:
1.页面自动刷新:把如下代码加入<head>区域中
<meta http-equiv="refresh" content="20">
其中20指每隔20秒刷新一次页面.
2.页面自动跳转:把如下代码加入<head>区域中
<meta http-equiv="refresh" content="20;url=http://jay-xu33.cnblogs.com/">
其中20指隔20秒后跳转到http://jay-xu33.cnblogs.com/页面
3.页面自动刷新js版
<script language="JavaScript">
function myrefresh()
{
window.location.reload();
}
setTimeout('myrefresh()',1000); //指定1秒刷新一次
</script>
ASP.NET如何输出刷新父窗口脚本语句
1. this.response.write("<script>opener.location.reload();</script>");
2. this.response.write("<script>opener.window.location.href = opener.window.location.href;</script>");
3. Response.Write("<script language=javascript>opener.window.navigate(''你要刷新的页.asp'');</script>");
JS刷新框架的脚本语句
//如何刷新包含该框架的页面用
<script language=JavaScript>
parent.location.reload();
</script>
//子窗口刷新父窗口
<script language=JavaScript>
self.opener.location.reload();
</script>
(或<a href="javascript:opener.location.reload()">刷新</a> )
//如何刷新另一个框架的页面用
<script language=JavaScript>
parent.另一FrameID.location.reload();
</script>
如果想关闭窗口时刷新或者想开窗时刷新的话,在<body>中调用以下语句即可。
<body onload="opener.location.reload()"> 打开窗口时刷新
<body onunload="opener.location.reload()"> 关闭窗口时刷新
<script language="javascript">
window.opener.document.location.reload()
</script>
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python数据类型bytes 和 bytearray的使用与区别
Go语言的type func()用法详解
python基于moviepy实现音视频剪辑
SQLServer三种开窗函数详细用法
![](https://img.aspxhome.com/file/2023/9/86879_0s.png)
微信小程序搭建及解决登录失败问题
![](https://img.aspxhome.com/file/2023/3/58253_0s.jpg)
Go项目实现优雅关机与平滑重启功能
Pycharm报错Non-zero exit code (2)的完美解决方案
![](https://img.aspxhome.com/file/2023/0/71980_0s.jpg)
常见前端面试题及答案
![](https://img.aspxhome.com/file/2023/3/131823_0s.jpg)
Win10下python 2.7.13 安装配置方法图文教程
![](https://img.aspxhome.com/file/2023/4/80624_0s.png)
完美解决ARIMA模型中plot_acf画不出图的问题
![](https://img.aspxhome.com/file/2023/1/61761_0s.jpg)
JavaScript调用ajax获取文本文件内容实现代码
![](https://img.aspxhome.com/file/2023/7/130467_0s.gif)
Django实现文件分享系统的完整代码
![](https://img.aspxhome.com/file/2023/8/97078_0s.png)
解决csv.writer写入文件有多余的空行问题
关于golang中平行赋值浅析
Oracle自定义脱敏函数的代码详解
在ASP中使用SQL语句之12:连接
利用pip安装python第三方库的4种方法
![](https://img.aspxhome.com/file/2023/0/63570_0s.png)
OpenCV图像修复cv2.inpaint()的使用
![](https://img.aspxhome.com/file/2023/5/96455_0s.jpg)
go语言发送smtp邮件的实现示例
![](https://img.aspxhome.com/file/2023/7/72727_0s.png)