<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>uvi</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<button id="btn" onclick="goceshi()">按钮</buton>
<script>
function goceshi(){
history.back();
}
</script> </body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>uvi</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<a href="index9.html">跳转到index.html页面</a>
<button id="btn" onclick="">按钮</button>
<script>
function goindex9(){
history.forward();
}
</script>
</body>
</html>

下面的例子演示:点击ceshi.html的链接跳转到index10.html登陆页面,然后输入正确的用户名("hello")后又返回到之前的页面ceshi.html

即利用了history.go(-1)

ceshi.html

 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>uvi</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<a href="index10.html">跳转到index.html页面</a> </body>
</html>

index10.html

 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>uvi</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<form>
<input type="text" id="username">
</form>
<button id="btn" onclick="safe()">按钮</button>
<script>
function safe(){
var name = document.getElementById("username").value;
alert(username);
if(name=="hello"){
history.go(-);//回到之前的界面
}else{
alert("输入错误");
}
}
</script> </body>
</html>

JS浏览器对象-History对象的更多相关文章

  1. JS window对象 History 对象 history对象记录了用户曾经浏览过的页面(URL),并可以实现浏览器前进与后退相似导航的功能。语法: window.history.[属性|方法]

    History 对象 history对象记录了用户曾经浏览过的页面(URL),并可以实现浏览器前进与后退相似导航的功能. 注意:从窗口被打开的那一刻开始记录,每个浏览器窗口.每个标签页乃至每个框架,都 ...

  2. Javascript进阶篇——浏览器对象—History对象

    History 对象history对象记录了用户曾经浏览过的页面(URL),并可以实现浏览器前进与后退相似导航的功能.窗口被打开的那一刻开始记录,每个浏览器窗口.每个标签页乃至每个框架,都有自己的hi ...

  3. JS BOM对象 History对象 Location对象

    一.BOM对象 BOM(浏览器对象模型),可以对浏览器窗口进行访问和操作 window对象 所有浏览器都支持 window 对象. 概念上讲.一个html文档对应一个window对象. 功能上讲: 控 ...

  4. JavaScript---Bom树的操作,内置方法和内置对象(window对象,location对象,navigator对象,history对象,screen对象)

    JavaScript---Bom树的操作,内置方法和内置对象(window对象,location对象,navigator对象,history对象,screen对象) 一丶什么是BOM ​      B ...

  5. JS中的history对象

    window.history指向History对象,它表示当前窗口的浏览历史. History对象保存了当前窗口访问过的所有页面网址. history.back()//后退到前一个网址 等同于 his ...

  6. JS---BOM基本知识 (顶级对象,系统对话框,加载事件,location对象, history对象, navigator对象)

    BOM JavaScript分三个部分: 1. ECMAScript标准---基本语法 2. DOM--->Document Object Model 文档对象模型,操作页面元素的 3. BOM ...

  7. 【JavaScript】BOM对象——Window对象&History对象&Location 对象

    1.Window对象: 表示浏览器中打开的窗口 setInterval():它有一个返回值,主要是提供给 clearInterval 使用. setTimeout():它有一个返回值,主要是提供给 c ...

  8. BOM 3.1 location对象 | history对象 | navigator对象 | 定时器 | 三大系列

    JavaScript分三个部分: 1. ECMAScript标准---基本语法 2. DOM--->Document Object Model 文档对象模型,操作页面元素的 3. BOM---& ...

  9. 分享关于浏览器对象 history对象

    window.history.forward() == window.history.go(-1) //返回下一页 window.history.back() == window.history.go ...

随机推荐

  1. [转] 用GDB调试程序(五)

    转:http://blog.csdn.net/haoel/article/details/2883 查看运行时数据———————        在你调试程序时,当程序被停住时,你可以使用print命令 ...

  2. Android - 消息机制与线程通信

    以下资料摘录整理自老罗的Android之旅博客,是对老罗的博客关于Android底层原理的一个抽象的知识概括总结(如有错误欢迎指出)(侵删):http://blog.csdn.net/luosheng ...

  3. 95秀-自定义对话框 dialog 合集

    普通的确认对话框 NormalDialog.java import android.app.Dialog; import android.content.Context; import android ...

  4. <display>标签的几个属性

    <display>这个标签个人觉得挺强大的,但是用不好的话就会成为个累赘,下面给大家分享一下他的几个属性. none:表示此元素不会被显示. block:此元素将显示为块元素,前后会换行. ...

  5. (转)background-position—CSS设置背景图片的位置

    background-position :在 CSS 中通过 background-position 属性可以调整背景图片的位置.因为在默认情况下背景图片都是从设置了 background-posit ...

  6. CSS优先级总结(转载)

    样式的优先级 多重样式(Multiple Styles):如果外部样式.内部样式和内联样式同时应用于同一个元素,就是使多重样式的情况. 一般情况下,优先级如下: (外部样式)External styl ...

  7. codesmith的使用

    新建一个C#模版. model类的模版代码如下: <%-- Name: 模型层代码生成模版 Author: XX Description: 根据数据库的内容生成模型层代码 Version: V1 ...

  8. eclipse中的web-inf下没有web.xml

  9. C#将图片字节流转为Base64直接放入html的img标签src属性中

    1,图片要转为byte[], 2,注意加上“data:image/jpeg;base64,”,这里jpeg可以换成其他. string html = "<img src='data:i ...

  10. 将图片转换为Base64

    string Imagefilename   硬盘路径 protected string ImgToBase64String(string Imagefilename) { try { Bitmap ...