gpt4 book ai didi

Javascript : go back with new parameters

转载 作者:行者123 更新时间:2023-11-29 14:56:55 24 4
gpt4 key购买 nike

history.back() 函数有问题。

我有三个页面 A、B、C:

  • 第一个 (A) 有一个到第二个 (B) 的链接,该链接包含参数 (?id=..)。
  • B 有一个链接到 C
  • 我使用 history.back() 从 C 返回到 B。

问题是 back() 函数实际上使用了包含参数的 A 到 B 链接(来自历史记录),但我需要更改这些参数。

所以我将 history.back() 更改为一个简单的 href 但是当然,现在如果我点击返回,我会返回到 C 页面(我不想要的)。

那么有没有办法使用不同参数的back()呢? (我使用 Angular,可能有什么帮助)。

A.html :

<body ng-controller="AuthentCtrl">
<div align="center">
<button ng-click="location.href = 'view/listing.html?id=' + id + '&first=' + newAuthent;">Go!</button>
<br/>
</div>
</body>

B.html

<body onload="init()">
<script>
function init(){
var params = location.search.substring(1).split('&');
id = params[0].split('=')[1];
var firstCo = params[1].split('=')[1];
// execute some code, function of parameters
}
</script>
</body>

C.html

<body>
<div align="center">
<button ng-click="history.back()">Go!</button>
<br/>
</div>
</body>

最佳答案

无法使用 javascript 更改您的历史记录。

您是否尝试过使用 referrer如果您来自页面“A”或“C”,请确定页面“B”上的属性?

关于Javascript : go back with new parameters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16297155/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com