<!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. .NET注册页面代码

    using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI ...

  2. python代码合并

    http://www.baidu.com/s?wd=python%E4%BB%A3%E7%A0%81%E5%90%88%E5%B9%B6&rsv_bp=0&ch=&tn=mon ...

  3. 2.Android Studio系列教程2——基本设置与运行

    原文链接:http://stormzhang.com/devtools/2014/11/28/android-studio-tutorial2/   一.项目结构   二.Android Studio ...

  4. Hadoop 停止Job

    1.查看所有正在运行的Job Hadoop job -list 2.根据Id停止某一个Job Hadoop job –kill <JobID>

  5. 在iptables和selinux中放行smb服务

    配置selinux [root@localhost samba]# getsebool -a | grep samba 查找selinux中对samba的限制项samba_domain_control ...

  6. Xcode 运行报错:“Your build settings specify a provisioning profile with the UUID ****** however, no such provisioning profile was found”

    iOS开发中遇到"Your build settings specify a provisioning profile with the UUID ****** however, no su ...

  7. intent.setFlags方法中参数值的含义

    intent.setFlags()方法中参数的含义 1.FLAG_ACTIVITY_NEW_TASK: 例如现在栈一的情况是:A    B   C(C位于栈顶),C通过intent跳转到D,并且这个I ...

  8. 模块SEO优化中{分类名称}分隔符去掉及只调用下级分类方法

    if($catid) { if($CAT['parentid']) { $seo_catname = ''; $tmp = strip_tags(cat_pos($CAT, 'DESTOON')); ...

  9. 不要依赖hibernate的二级缓存

    一.hibernate的二级缓存   如果开启了二级缓存,hibernate在执行任何一次查询的之后,都会把得到的结果集放到缓存中,缓存结构可以看作是一个hash table,key是数据库记录的id ...

  10. twisted(2)--聊天系统

    我们今天要做一个聊天系统,这样可以和我们之前flask api那系列文章结合起来:其次,聊天系统最能代表tcpserver,以后可以套用各种模型,比如我们公司做的物联网,其实就是把聊天系统简化一下. ...