当前位置:网站首页>js跳转页面并刷新(本页面跳转)
js跳转页面并刷新(本页面跳转)
2022-07-27 17:44:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
1、跳转常用方法:
window.location.href="index.php";
window.history.back(-1);//类似于按钮,参数是负几,就后退几次。
window.navigate("index.jsp"); //navigate对象包含有关浏览器的信息,也可以作为页面跳转,后面直接加要跳转的地方。
self.location.href=index.htm;
//self指代当前窗口对象,属于window最上层的对象;
//location.href 指的是某window对象的URL地址.
//self.location.href指当前窗口的URL地址,去掉self默认为当前窗口的URL地址.
top.location=index.php;
//top 属性返回最顶层的先辈窗口。
//该属性返回队一个顶级窗口的只读引用。
//如果窗口本身就是一个顶级窗口,top 属性存放对窗口自身的引用。
//如果窗口是一个框架,那么 top 属性引用包含框架的顶层窗口。
[javascript] view plain copy print?
location.replace(document.referrer);
document.referrer
history.go(-1);//不刷新页面
[javascript] view plain copy print?
history.back();//不刷新页面 2、Javascript刷新页面的常用方法:
[javascript] view plain copy print?
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 3、自动刷新的方法
自动刷新页面的方法:
1.页面自动刷新:把如下代码加入<head>区域中
<meta http-equiv="refresh" content="20">
其中20指每隔20秒刷新一次页面.2.页面自动跳转:把如下代码加入<head>区域中
<meta http-equiv="refresh" content="20;url=http://www.baidu.com">
其中20指隔20秒后跳转到http://www.baidu.com页面3.页面自动刷新js版
[javascript] view plain copy print?
<script language="JavaScript"> setTimeout('window.location.reload()',1000) //指定1秒刷新一次 </script>
JS刷新框架的脚本语句
//如何刷新包含该框架的页面用
[javascript] view plain copy print?
<script language=JavaScript> parent.location.reload(); </script>
//子窗口刷新父窗口
[javascript] view plain copy print?
<script language=JavaScript> self.opener.location.reload(); </script>
( 或 <a href="javascript:opener.location.reload()">刷新</a> )
//如何刷新另一个框架的页面用
[javascript] view plain copy print?
<script language=JavaScript> parent.另一FrameID.location.reload(); </script>
如果想关闭窗口时刷新或者想开窗时刷新的话,在<body>中调用以下语句即可。4、jquery方法
$(location).attr('href', 'http://www.jb51.net');
$(window).attr('location','http://www.jb51.net');
$(location).prop('href', 'http://www.jb51.net')发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/128190.html原文链接:https://javaforall.cn
边栏推荐
- Membership card head assembly usage document
- 邬贺铨:因地制宜 数字化技术赋能“双碳”实践
- 使用cpolar建立一个商业网站(5)
- Chapter 3 basic operation
- PMP每日一练 | 考试不迷路-7.27(包含敏捷+多选)
- 华为全联接大会2022开启曼谷之旅;Facebook推视频收入分成功能,创作者可获20%分成…
- 第2章 入门
- C#网络应用编程,实验一:WPF练习
- ms721负载测试
- 2022 love analysis · smart community manufacturer panoramic report manufacturer solicitation
猜你喜欢
随机推荐
Unified Modeling Language (UML) specification
YY English learning about fish
产品经理:排查下线上哪里冒出个“系统异常”的错误提示
New library online | cnopendata detailed address data of all patents in China
11.5.OSPF
使用cpolar建立一个商业网站(5)
Qt的QTextToSpeech类实现语音播报功能
[论文阅读] Rich Feature Hierarchies for Accurate Object Detection and Semantic Segmentation
PKI/TLS 工具之CFSSL —— 筑梦之路
调整数组使奇数全部都位于偶数前
Function priority
Compiling ncnn with vs
Static test. 2021.01 .13
软件配置 | tigerVNC的下载、安装及配置
信道容量、信道带宽基本概念的理解
Capacitance in series and in parallel and capacitance in series and balance resistance
ViewUI 中 DatePicker 日期选择器在 IE11 浏览器中兼容解决方案
Sword finger offer 25. merge two sorted linked lists
如何快速提升抖音小店三分钟回复率?哪些情况会影响抖音小店回复率呢?
TS2532: Object is possibly ‘undefined‘









