首页 > 解决方案 > 链接不记得之前的页面

问题描述

我在 CSS 网格中工作。我有一个专栏,我在其中添加了背景图片。link-x我已使用以下 javascript将该背景图像制作成超链接 ( )。

问题不在以下。如果我执行以下操作:

我去https://my-site.com并点击超链接link-x。我在浏览器中单击“返回”,这意味着我应该返回到https://my-site.com。但是当我单击返回时,我将进入我的浏览器起始页。

浏览器似乎不知道我在我的网站上访问过的上一页。

有谁知道这是否有解决方案?

$('.sbp-item1').click(function(e) {
  window.location.replace("https://my-site.com/link-x");
});
.sbp-item1 {
  grid-row: 1 / 3;
  grid-column: 1/9;
  height: 520px;
  display: flex;
  justify-content: flex-end;
  flex-direction: column;
  background-image: url("/Static/Cms/d1bd45c5-f39e-4b8f-8c47-f7fe5497b1a4.jpg");
  cursor: pointer;
}
<div class="sbp-wrapper">
  <a class="sbp-item1 bg-img" href="https://my-site.com/link-x"></a>
</div>

标签: javascriptjqueryhtml

解决方案


的全部意义replace在于它替换了浏览器历史记录中的当前页面。

location如果要正常导航,请将新 URL 分配给:

window.location = "https://my-site.com/link-x";

推荐阅读