在HTML和JS中实现网页跳转的方法
最编程
2024-08-08 10:44:37
...
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>
推荐阅读
-
Java 8新特性探究(十三)JavaFX 8新特性以及开发2048游戏-JavaFX历史## 跟java在服务器端和web端成绩相比,桌面一直是java的软肋,于是Sun公司在2008年推出JavaFX,弥补桌面软件的缺陷,请看下图JavaFX一路走过来的改进 从上图看出,一开始推出时候,开发者需使用一种名为JavaFX Script的静态的、声明式的编程语言来开发JavaFX应用程序。因为JavaFX Script将会被编译为Java bytecode,程序员可以使用Java代码代替。 JavaFX 2.0之后的版本摒弃了JavaFX Script语言,而作为一个Java API来使用。因此使用JavaFX平台实现的应用程序将直接通过标准Java代码来实现。 JavaFX 2.0 包含非常丰富的 UI 控件、图形和多媒体特性用于简化可视化应用的开发,WebView可直接在应用中嵌入网页;另外 2.0 版本允许使用 FXML 进行 UI 定义,这是一个脚本化基于 XML 的标识语言。 从JDK 7u6开始,JavaFx就与JDK捆绑在一起了,JavaFX团队称,下一个版本将是8.0,目前所有的工作都已经围绕8.0库进行。这是因为JavaFX将捆绑在Java 8中,因此该团队决定跳过几个版本号,迎头赶上Java 8。 ##JavaFx8的新特性 ## ###全新现代主题:Modena 新的Modena主题来替换原来的Caspian主题。不过在Application的start方法中,可以通过setUserAgentStylesheet(STYLESHEET_CASPIAN)来继续使用Caspian主题。 参考http://fxexperience.com/2013/03/modena-theme-update/ ###JavaFX 3D 在JavaFX8中提供了3D图像处理API,包括Shape3D (Box, Cylinder, MeshView, Sphere子类),SubScene, Material, PickResult, LightBase (AmbientLight 和PointLight子类),SceneAntialiasing等。Camera类也得到了更新。从JavaDoc中可以找到更多信息。 ###富文本 强化了富文本的支持 ###TreeTableView ###日期控件DatePicker 增加日期控件 ###用于 CSS 结构的公共 API
-
在js中实现大顶堆和小顶堆的操作(javascript)
-
配置HP FC存储设备多路径驱动的方法在linux和Windows操作系统中即可实现
-
在JSP中引入Java和Vue的实现方法
-
在HTML中实现div元素垂直居中的三种方法
-
两种在JS中实现页面跳转的方法:原页面跳转与新开标签页
-
在JavaScript中实现页面跳转并传递参数的方法
-
在HTML和JS中实现网页跳转的方法
-
在JavaScript中实现页面跳转和新开窗口的技巧
-
在React、TypeScript和Antd中实现页面内的局部路由跳转