首页 > 解决方案 > 如何制作不会添加到浏览器历史记录的链接

问题描述

我想创建一个秘密 URL,它将对用户进行身份验证以执行某些操作,但它不会出现在浏览器历史记录中。

例如,我认为这样的事情会起作用

  1. 特殊链接,例如https://example.org/page#specialHashGivesAccess通过电子邮件发送给合适的人。为此目的,电子邮件被认为足够安全。
  2. 页面上运行的 Javascript 通过 ajax 将秘密发送到服务器,该服务器对其进行检查并返回一个临时哈希值。
  3. Javascriptwindow.location.replace使用临时哈希对页面进行处理。
  4. 该应用程序然后检查临时哈希,如果 OK 则显示内容。
  5. 临时哈希会在短时间内过期,也可以手动过期。
  6. 原始特殊链接 (1) 不在浏览器历史记录中。

此外,执行此工作的脚本;应用程序脚本和 ajax 服务器是远程的。即生成example.org/pagehas<script src="https://siteb.com/app.js">和ajax 的siteA 是使用CORS 完成的。

但是,在我的测试中它似乎并不可靠,我specialHashGivesAccess在我的历史中发现。

有没有办法做到这一点?

标签: javascriptbrowser-history

解决方案


It can't be done (at the time of posting this answer).

While there are many methods for manipulating the session history, it is not possible to prevent an entry being created in the global history, or to overwrite the first page load request stored there.

Therefore the solution I'm going to go with is along the lines of

Hi,

To access the service you can use the following link and password:

If nobody else uses your browser you can use the following shortcut link to save you entering the password, however note that this will give access to the service to anyone that has access to your browsing history.


推荐阅读