一般浏览记录模式

假设有三个页面, start.html, 通过点击start.html上的链接跳转到 first.html, 然后点击first.html上链接跳转到 second.html, 那么在history中记录的历史如下链表:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlcAAACHCAIAAAC0+OvVAAAOv0lEQVR4nO2dQXKjMBBFOW0OkNukfBOfIwtfgI0vwSzIEAyy05Za0m94r1xTDuMvk3bTX7QIHiZtbuPYexfCQKzsJGM1DF/t90Qf8soOsbJjj1XtA3OoOno5ZJUdYmUHF7RDXtkhVnZwQStklR1iZafEBUvijFZfWwLHoJ14Lhgxm9GifUuLC6JFK6jdH5i+74sLokX7Ay6IFq2gFhdEi7aRlnXBJHT57Ejl82G0Ki7YC45AO8TKDi5oh7yyQ6zsxFsX7AVZZYdY2cEF7ZBXdoiVHVzQClllh1jZYV0QLdooWhUX1I8UWrSF2gO7YAkRZ1cRPyO0z1BZF9SPFFq0hVpcUOp9I0Ks7OCCaNHKaVkXTEJlt0Os7Ai54G0cefDgcRvHYfjqvg88ePDYPGofmFwdcxyIlZ1krA58LliSG2jR9tWqXB3TCyq7HWJlp8QF9asGWrRH0qq4oH6k0KIt1B7YBUuIOLuK+BmhfQZXx6BF20iLC0q9b0SIlR1cEC1aOe2B1wVLoLLbIVZ24rlgL8gqO8TKztlcUGq20UDbi4j73It464K9IKvsECs7uCBatFG0uCCV3QqxsnO2dUG0aONqVVxQP1Jo0RZqD+yCJUScXUX8jNA+Q2VdUD9SaNEWanFBqfeNCLGygwuiRSunPfC6YAlUdjvEyk48F+wFWWWHWNk5mwtKzTYaaEuI+PseW6uyLtgLKrsdYmUHF0Rbg4i/r74WF6SyWyFWds62Loi2DRyDduK5YMRsRov2Le2BXbCEiJWdWOkTb10w4pGPFu1bWlxQ6n17EfEzigguiBatnPbA64IlnK2yS+Uk2knHBXtxtiOwBGJl52wuqF/pfLUlRPx9j61VWRfsBZXdDrGygwuiRRtF284Fb+M4P9jCFrUtbd5lGL5qv9fyb4M38oqzWjIob1l+FNkf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Gdz/pToo4DqqwLckW7PrJu1FH7zLFmbYYrLHctz3OUvdbuWMb3Tbp+4T5jgUaodXbeOTs6jQv6zjVOOBrVasOLk5hkTv7ZeBFvMdUYsHBM5RkS2ihaFRdsg2/Hybc7FGXfYOb1VCPDBY/UYnprzCVWGWPqV1i0+lqVdcE2DLs1kpJOzuR62fF+3wqfu+8b3Rg7eeeC50S/SqI9tvZcLrjvvfS65mr/vvbR7OtVXteYlffB9I+EBlrjwSa1z+Las0Gs7MRzwV7rgiXXXDl2ct7qNVmuXXw2Wsbv67IuGLHC4oJoj6Q9G0Lrgrdx5MGDx20ch+Gr+z7w4MFj86h9YAqdC7przwaxspOMFeuCSSIe+2iPpD3XNaJ7qOx2iJUdXNAOeWWHWNkpcUFfcMHjQKzs4IJ2yCs7xMoOLmiFrLJDrOzggnbIKzvEyk48F9TvHaNFW6jlGlG0aAW1KuuC+pFCi7ZQiwuiRSuoxQXRom2kxQXRohXUqrhgL+iz2yFWdlgXtENe2SFWduKtC/aCrLJDrOzggnbIKzvEyg4uaIWsskOs7OCCdsgrO8TKTjwX1O8do0VbqGVdEC1aQa3KuqB+pNCiLdTigmjRCmpxQbRoG2lxQbRoBbUqLtgL+ux2iJUd1gXtkFd2iJWdeOuCvSCr7BArO7igHfLKDrGygwtaIavsECs7uKAd8soOsbITzwX1e8do0RZqWRdEi1ZQq7IuqB8ptGgLtbggWrSCWlwQLdpGWlwQLVpBbTsXvI3j/GALWw6/Zfl3/Zph+NLZQ7aw5dhbln//VC0HZqX94eqY40Cs7CRjxdUxScgrO8TKjj1WKlfH9IKsskOs7OCCdsgrO8TKjo4L/gM/xceukn68dgAAAABJRU5ErkJggg==" alt="" />

如下代码例子, 页面跳转均以 链接实现。

start.html

<html>
<head>
<style> </style>
</head>
<body>
<a href="./first.html">go to first html</a>
</body>
</html>

first.html

<html>
<head>
<style> </style>
</head>
<body>
<a href="./second.html">go to second html</a>
</body>
</html>

second.html

<html>
<head>
<style> </style>
</head>
<body>
here is second html
</body>
</html>

某个页面被浏览过后,在history中被替换

对于一种特殊场景, 此页面用户看完后, 不想让用户再看到, 例如特定页面上,让用户选择一个条件,此选择是一次性的, 不能让用户多次选择, 点击回退按钮不显示此页面.

使用 location.replace接口, 实现代码如下, first.html页面点击连接后, 跳转到second.html,  first.html页面在history中被second.html代替。

浏览到 first.html history记录

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUIAAABZCAIAAADEqbonAAAGmElEQVR4nO2d0ZGDIBCGqTYF2M2NnViHD2kgL2nCezBRBKIIC4J832RuPOOuZsMvuxFUTUE8X68wwwYhVv44Y6XUX/4jyUNM29BtVf7dtwax8idGxlKSqNH2Ahlji+0p2xvLOAZkjG1Ntsj4cL/IGNvSbW9cG8dAbZwVYuVPazKuuDZuDWLlDzIOs1X6P8/Xa36xhjU+a/LsRam/1Pta/mbYkVSc9c2ojbEt3ZafuA73i4yxLd32xjKWskXGRdu2RoyMW+NiGbcGsfIHGfuDjLNCrPxBxv4g46zUmMwXZUttfGhLbYxtVtvHw728Y7sv48XJ8/WyHXqi73f/CPdtnew4DI7z47HaPh7IGNvsto/HpJSaG7RSSqlPIwxe1h2K+JxdzW5FfOoOBX2uYdyL929Iqv0hVgaykpuXBSWnnxoEfQqetgyfk4+MnSlBTDLgXL6xt5hk75YsXRMOpXx69cZ2SvB8vSLPc1LnY9l0JdGxwYLsubJNh9O2wfvWxuIpgWwKVPixFVujXmWrRwmC2TQ2HwOjj4pEto8q3Ftk3IqVYowtMhYnsDYOpkFvUhdCWrCFMDgpJodmDSk4nVSTBYUxxw0ZG9CcREDGmUDGTmhO4hDN5NRYo1Ib1wUyTk6NckLG5bNJqnfuA7Te6YcsKAg7qX5G3CMqxk/ONYfHTHMSgdo4E9TGTmhO4hDN5CBjSA0yTg4y1kkxwLhBAsdUkwUFEJ9U39JWdmxvs5yeb4yMw0DGTtCwFLHzjeEQxlT/gvmbIoTPN4ZTEDcbegURouYbwyni5xvfEmo0ES6eb9wOxM0JMhaH2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mScHGQMKSCpzgS1sY34mGrx4UnlO5yYb5wTZOxkmTGy6U8iljdzfSR8GnNa4n0uw3JFPq/hcyKpzkCxcrrQ9pfkZtuAZr1MQQmThG3rLznP/TpPW5HHfNl84wa9MabaYGfGiPMUoNRfsMMwyndo+Dz9fGPBZCDST13HBjP758oAGZdfyiaqjTe3A/CxUVadEJMMTD8SjOBlwRomxbHxS7U/Yb1xm+ixCpxvHNM0YxIMe7/+3vxrNs9eItibPyXXt9lsPWVc1DFntg2sjYN3byQDZzH2eypd8fkF9Ze3gM8rUhuX0EQut0XGh7ZquWcSL15lvpT6u/wYCn8FXnB6Uu95Q6z8ccaK2tiJHqt/c8k4pLH26RMAAAAASUVORK5CYII=" alt="" />

从first.html跳转到 second.html后, history记录

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAU4AAABOCAIAAADARmiKAAAGs0lEQVR4nO2dXbKjIBCFWW0WkN3ccieuw4dswBc3wTyQIS2IInTzI+erW1OGsVuDfaRRIEp7fNbVL1Tqzy8Eh3UFDkFdxRNfV/HCVJGHgdQPQfhe8np9Nz7rardZHDrbT3Lox1XIpy/MUExC6llA6jG8XlopZQJUKaXUN+qSt6lDFp/GlXHL4pM6TPBj4sr3Sb/1//JKUs8Jfdg+1ZZXlmabUZb09sHok/HW5vjc1+0dqTu5Qb7U0xKYkzC6dJgQgiyJJT3u3W/dl1xzbG0Tx8WADkM+b/fVL1Mspf4S7pEtp1gSPg9TrBB9yTXZtsGecHcO9T7pOO+rh3B7F3qkFEvCJ++N/BnQWgLJHFZjSquu205gimVETTl8BpC6HFl99XzadyjhM5RiASBHSgKP+24+t6qxo/42iy3IhCGB/6wrpM7OZ13NX6jEfjzZR6LEPwHpc0Z0sWCq0bnbGqnTCrf/OhcFF6AaPbbMye/VIXUhsobQgGQQ06Awt6WOGGUB1Qjk4HnZhhgFciC6WOCROihPX/3tHFtIXQ5IvQ542QYKg756HSB1H4nhTwMSPwYeUgfVuDULCITgn68OAC/QORcx89VDi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p99bdzbDtcmqJFeH50GbAw2su2eKBzFhiWpkCKlU+b011asMXv/LLAs+AUUiwWENM+aEhYiF+a4vplGy4DC6hGHzz0leN2Xx3NEQtIjkBhbi9NgRQrH/TVgSgYA98rPcoVA2MrgjHwvdKXXHNsIXU5IPU6IKZBYTAGvg6oRiAH+uqgdRBdLPBIHZSnr/52ji2kLgekXgeMgQeFQV+9DpA6kIPnZRukDoRgH6DF/mNE7TvUvGPgARDCjhemLUrONh2AzOKT/Sd07Uhzlu/r+KSgr14HJEchXi93saPMbfZftuaVpd63w3dtQ3UVM189hMgY+F4yIl6fGAMfIn8ylXPcWw5jzjnkMGcpDmdlqFscHpehVTfnpAZLsSR80otxudyX/Vh4vTf/BOL9JJwzrQ0apsnnbFRkPprtzHNmOUNaYs8q8gxjzpn6OV9bzv7rHMKdr84ldXZZaoEUS8Jn/I28r5YZtm3apqxCo8ntLcbjOewT4CVm1NdNLEcjJ/RHQ0rqTq81X+rj9NVpXUmc5JOA1OPJkXpwz8jD3G3VBwHhGw/qKp4OpN5+3wa2sH2SLaQOW9gOYZs1Wg5Shy1se7GNl/o/fbfqS+ziGjUAAAAASUVORK5CYII=" alt="" /> 这样, 当前显示second,点击回退按钮, 回退到start页面。

实例代码,其他两个不变。

first.html

<html>
<head>
<style> </style>
</head>
<body>
<a id="go2scond" href="#" onclick="go2second();">go to second html</a>
<script type="text/javascript">
function go2second()
{
location.replace("./second.html");
}
</script>
</body>
</html>

某个页面之前的所有页面不能再被浏览

如果某个页面之前的页面是一次性显示, 对于用户来说不能再被显示, 例如当用户选择了所以后的内容后,在最后一步确认后, 不能再被修改, 用户企图通过浏览器回退按钮重新查看之前的页面, 这中条件下, 想法让其失效。

history对象, 没有提供清空之前浏览页面的接口, 此需求可以通过js脚本判断实现:

例如下面demo, 用户从start.html浏览到 first.html页面,后浏览到second.html,  然后用户点击回退仍然显示 second.html

修改first.html代码如下

具体实现原理是, 在之前不能浏览页面中的最后一一个页面脚本中,添加history.forward(1), 让其向后自动跳转到后面一个页面, 对于第一次访问此页面, 由于没有后面一个页面, 所以不会执行, 当浏览到后一个页面后, 这时此页面在history中就有了后一个页面, 通过后退按钮, 当加载此页面时候, 就会自动跳转到后一个页面。

<html>
<head>
<style> </style>
</head>
<body>
<a href="./second.html">go to second html</a>
<script>
//HTML禁用回退上一浏览页面按钮
/*
加入有以上代码的页面无法回退到它
例如A页面有这段代码,从A链接到B页面,这时一旦在B页面上按回退按钮,则无法回退到A页面
*/
if(window.history.forward(1) != null)
{ } </script> </body>
</html>

浏览历史(前进 和 后退)与刷新的差别

浏览历史(前进和后退),仅仅加载已经访问过页面的 URL, 如果其中有一个页面是以 form 表单 post 方法提交后显示的, 浏览历史 也仅仅是加载 此页面的url, 并不提交 post的数据。

刷新, 如果有个页面是以提交数据显示的, 则刷新会提示用户,是否要重复提交数据:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhUAAAB4CAIAAADKc5eEAAAfFUlEQVR4nO3de1xUZf4H8C/wS9p+r+23u26+7GZrahaiMmMpiZimoitQIKKoiGigROoEkpWlrbpWpLZa6nbdn5rrL/OWrZqtWmlbud5AlJsOMMzMmTvDMNwUwef3xxlmhjNznnnOgItO33m9X7wOZ54557nN8+EwwwCk4w1izwXFFQbFFcLEUphYCpPLHBJUkFQNM7WQpue/Bs01QZoRZuoh1QhpRkhtl2JGAcqKAs0MAwpAwqdtxydyIo+DRDPE6iGRg0QOYvWQaIZYM8TqIVYDMVqI0UKsBmL1EKuHWDPEmOCpImFeOLf42OixoCE0t63nMnLfKnLfKtJvDRm4nsjWEdkmMnIjGbmRRG8m0ZvJU38VxRdAgYcy6Og21e2TCt0kngPNr97Or2Jk64T6rSH91pCey0iPha3wVBHIfhLmR1BcYfBsY48FDcEL60LzbvRcRpwR0jef9M0nA9eTQRtcZJsc3HcihBDqdgPXO7h/y8cAf0nAr+pO/dZ0+JZf+Z34OOi5jIQq2kIVbZBSD1FFrvyAsachQQ1Jl4MyzUGZZlhQwwteWBe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zzAyGEEDtXfoTKMT8QQgixgtFKeHAb5gdCCCFpMD8QQgj5w5Uf+PoHQgghdvj6OUIIIX9gfiCEEPIH5gdCCCF/QLQSPz8RIYSQZJgfCCGE/OHKD7i34E5Z+e+mcHyKhD5rYgGT6hBCCP3iRCth8Lft+dFrH/TZCn22Qp9t7Rtdaxubrj7vg12ty8/L2DNdfkDWhmxj1cUzgRl7Dbu2IRIO2LW667nZ5afuxiZ3tVv8OdL1tkKfz6DPNrj/Y+i5DuD3H0LPdQghhJAk/w8iDwtgpTmDxQAAAABJRU5ErkJggg==" alt="" />

demo测试代码:

start.php form提交数据到 first.php

<html>
<head>
<style> </style>
</head>
<body>
<form action="./first.php" method="post">
<input type="text" name="para" id="para" value="para" />
<input type="submit" value="submit" />
</form>
</body>
</html>

first.php是被提交数据后显示的, 使用刷新则会提示是否要重复提交数据。点击回退和前进, 都没有重复提交数据提示。

<html>
<head>
<style> </style>
</head>
<body>
<a href="./second.php">go to second html</a>
</body>
</html>

second.php

<html>
<head>
<style> </style>
</head>
<body>
here is second html
</body>
</html>

通过改造, 在first.php中添加 302 跳转, 直接跳转到 second, 可以避免 用户看到数据提交的页面 first.php, 同时尝试前进和后退按钮, 也不能浏览到first.php,说明在history中不会记录跳转的中间响应(从应用上也不会记录, 因为如果记录, 则回退按钮则永远不能回到start.php页面, 给用户带来不便)。

<?php
//重定向浏览器
header("Location: /replaceTest/second.php");
//确保重定向后,后续代码不会被执行
exit;
?> <html>
<head>
<style> </style>
</head>
<body>
<a href="./second.php">go to second html</a>
</body>
</html>

history中记录的链表同replace

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAU4AAABOCAIAAADARmiKAAAGs0lEQVR4nO2dXbKjIBCFWW0WkN3ccieuw4dswBc3wTyQIS2IInTzI+erW1OGsVuDfaRRIEp7fNbVL1Tqzy8Eh3UFDkFdxRNfV/HCVJGHgdQPQfhe8np9Nz7rardZHDrbT3Lox1XIpy/MUExC6llA6jG8XlopZQJUKaXUN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

浏览器浏览记忆(history)几则技巧记录的更多相关文章

  1. BOM 浏览器对象模型_当前窗口的浏览历史 history 对象

    当前窗口的浏览历史 window.history 对象 保存了当前窗口访问过的所有页面网址 由于安全原因,浏览器不允许脚本读取这些地址,但是允许在地址之间导航 history.back() 相当于 h ...

  2. 手机浏览器浏览WebApp弹出的键盘遮盖住文本框的解决办法

    手机浏览器浏览WebApp弹出的键盘遮盖住文本框的解决办法 最近碰到Android微信内置浏览H5页面,因为其中的文本输入框(input)放置在靠近页面的中下方,点击文本框以后,则输入框会被弹出的手机 ...

  3. vim 使用技巧记录

    vim 使用技巧记录 1.批量注释与取消注释 命令格式:起始行号,结束行号s#^#//#g 例如: 注释代码3到15行,"//"可以是其他的"" :3,15s# ...

  4. 直接拨号、将电话号码传入拨号程序、调用拨号程序、调用系统浏览器浏览网页、调用系统程序查看联系人、显示系统设置界面和显示Wi-Fi设置界面代码

    直接拨号.将电话号码传入拨号程序.调用拨号程序.调用系统浏览器浏览网页.调用系统程序查看联系人.显示系统设置界面和显示Wi-Fi设置界面代码 拨打号码的代码如下: Intent callIntent= ...

  5. 微信内置浏览器浏览H5页面弹出的键盘遮盖文本框的解决办法(转)

    最近在做微信公众号的内嵌页面,发现点击输入框时键盘盖住文本框,找到一段代码解决了这个问题. iOS和android手机都已亲测,需要的可以直接拷贝到代码中使用. js代码如下: $(function ...

  6. eclipse 怎么 直接查看 文件所在位置 显示在文件管理器中。用浏览器浏览。

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha eclipse 怎么 直接查看 文件所在位置 显示在文件管理器中.用浏览器浏览.

  7. Python requests库模拟浏览器行为的一些技巧记录

    如下都是一些经验之谈,不定期更新,喜欢可以关注哦. 忽略ssl报错 一些证书问题会导致程序报错,解决方法为在发送请求的时候,带上verify=False参数即可: result = requests. ...

  8. TypeScript和JavaScript的一些小技巧记录

    项目里使用到的技巧,记录一下,会持续更新. JS的技巧完全可以使用到TS上哦. JS 向下取整 Math.floor(4.5); 简写: var num = 4.5; ~~num; num <& ...

  9. Linux History安全问题【保存记录防止删除】+完善Linux/UNIX审计 将每个shell命令记入日志

    2011-09-27 22:11:51|  分类: rhel5_033|举报|字号 订阅       Linux利用PROMPT_COMMAND实现审计功能 这个系统审计,记录什么用户,在什么时间,做 ...

随机推荐

  1. background常用属性

    background-image:url('图片位置');//设置背景图片的位置 background-repeat:no-repeat;//图片是否重复显示(不重复) background-posi ...

  2. 【Oracle】多次提交造成性能慢及处理方法

    [问题背景] 2013-08-02 为某地市做了1个脚本用于帮客户账户添加一个新的账本.犯了一个很二的错,存储过程如下(SQL记录用户以后查询),一晚上只执行了190W数据 脚本如下 数据库中总共有5 ...

  3. C语言(4)

    C语言(4)--数据类型 C语言在用“/”是,注意左右两边都是整数时,商也是只有整数部分. 下面介绍一下C语言常用的数据类型:  注意: 1.char类型数据范围:256中字符. 2.float和do ...

  4. Linux_记录ping命令的日志包括时间戳

    while true; do ping -c 1 www.baidu.com | awk '{print "["strftime("%F %H:%M:%S")& ...

  5. 通过hibernate session.connection()获得数据库连接时,导致的查询缓慢甚至假死机问题

    在使用hibernate的应用中,如果需要直接使用Java.sql.Connection,一般我们是通过hibernate的session.connection()获得的,然后session.clos ...

  6. C#中的接口

    C#中的接口(转) 转自:http://www.cnblogs.com/zhenyulu/articles/377705.html 本文中所有图示纯为个人理解(参考了Assembly中元数据的存储方式 ...

  7. Linux 常见的单词缩写

    命令缩写:ls:list(列出目录内容)cd:Change Directory(改变目录) su:switch user 切换用户 rpm:redhat package manager 红帽子打包管理 ...

  8. LongListSelector with bindable SelectedItem

    using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using Microso ...

  9. Equal Sum Sets

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=49406 题意: 输入n,k,s,求在不小于n的数中找出k个不同的数 ...

  10. uploadify 自动访问url 初始化 自动请求

    摘要: uploadify 自动请求url, 初始化时自动请求url解决方法. 项目中使用了uploadify 上传图片,当访问到上传页面url,uploadify初始化时再一次访问该url 当我在配 ...