HTML 如何实现页面跳转(HTML 跳转到指定页面)
最编程
2024-03-21 22:08:11
...
大家好,又见面了,我是你们的朋友全栈君。
1、html中使用meta中跳转,通过meta可以设置跳转时间和页面
<head>
<!--只是刷新不跳转到其他页面 -->
<meta http-equiv="refresh" content="5">
<!--定时转到其他页面 -->
<meta http-equiv="refresh" content="5;url=index.html">
</head>
2、通过javascript中实现跳转
1 // 直接跳转
2 window.location.href='index.html';
3 // 定时跳转
4 setTimeout("javascript:location.href='index.html'", 5000);
3、html跳转上一页的方式
window.history.go(-1);或者window.history.back(-1);
1 <script type="text/javascript">
2 var wrong = document.getElementById('btn');
3 wrong.onclick = function() {
4 window.history.go(-1);//返回上一页
5 window.history.back(-1);//返回上一页
6 }
7 </script>
在html中写
<a href=”#” onClick=”JavaScript :history.back(1);”>返回上一页</a>
<a href=”#” onClick=”javascript :history.Go(-1);”>返回上一页</a>
在Js中网页跳转的写法
1、window.location.href
1 window.location.href="http://www.baidu.com"; //在原有窗口打开
2.window.navigate方式跳转
1 window.navigate("http://www.baidu.com");
1 function toBooks() {
2
3 //在原有窗口打开
4 window.location.href = "http://www.baidu.com";
5 //打开新的窗口
6 window.open("http://www.baidu.com");
7 }
直接跳转加参数
<script language="javascript" type="text/javascript">
window.location.href="login.jsp?backurl="+window.location.href;
</script>
推荐阅读
-
HTML+JavaScript+CSS3实现人脸识别页面,前端抓取base64格式的照片以文件形式传递给后端,如果识别成功则跳转到主页面,失败则自动关闭人脸识别返回本页面+vue刷新页面没有空白页面闪烁
-
HTML 如何实现页面跳转(HTML 跳转到指定页面)
-
实现 HTML 页面锚点定位和跳转的 4 种方法-第 4 种方法
-
如何在H5页面中利用HTML5的qrcode功能实现实体二维码的扫描与识别
-
实例演示:如何在小区管理系统的前端HTML页面中实现关键代码——打造模板步骤详细解析
-
如何在Vue中通过iframe引用HTML页面并实现代理两者间的方法调用操作
-
在React和Vue中,我们是如何玩转router的? - 使用HTML5 History API,React Router利用pushState和replaceState方法在不刷新页面的情况下管理导航历史。它像这样工作: 1. 当URL发生变化时,React Router悄悄地“监听”浏览器地址栏的改动,主要通过popstate事件来察觉url更改。 2. 随着URL的变化,Router会对照预先设定好的JavaScript路由配置对象,依据一套规则找出与当前URL匹配的路径。 3. 一旦找到合适的路线,React Router就会如魔法般地渲染相应的组件到网页上,从而实现了页面内容的实时更新。让我们来看一个React Router实际运用的例子。
-
如何在HTML中让网页 footer 固定在页面底部(多方法实现指南)
-
如何用HTML5打造专属七夕的情人节表白页面:包含JavaScript实现的创意外太空表盘与Canvas元素设计