简体   繁体   English

我需要使用浏览器按钮返回上一个动态页面

[英]I need to use the browser button to go back to the previous dynamic page

For example: I'm on this page, ciphxs? 例如:我在此页面上,ciphxs? model = XS% 20Max & screen = 6.5 & color = 1 & capacity = 64GB 型号= XS%20Max&屏幕= 6.5&颜色= 1&容量= 64GB

Clicking to go back I go to this page 点击返回我去这个页面

ciphxs? ciphxs? model = XS% 20Max & screen = 6.5 & color = 1 型号= XS%20Max和屏幕= 6.5&颜色= 1

Then clicking again would return to that page 然后再次单击将返回该页面

ciphxs? ciphxs? model = XS% 20Max & screen = 6.5 型号= XS%20Max和屏幕= 6.5

I have a button that does this behavior, but I would use the browser button. 我有一个执行此操作的按钮,但是我将使用浏览器按钮。

I am currently using typescript, but it would be nice to use JS even for the solution. 我目前正在使用打字稿,但即使是解决方案也可以使用JS。

This is the div to back to the earlier page. 这是返回上一页的div。

back() {
    this.capacity = null;
    this.canOrder = true;
    this.accepted = false;
    this.canOrderSubsidized = true;
    $(".final_selector").fadeOut(300)
    $(".capacity_selector").delay(300).fadeIn(300)
    $(".backCapacity").fadeOut(300)
    $(".backColor").delay(300).fadeIn(300)
  }

The div makes the result, but i want to make with the browser back button. 的div使结果,但我想用浏览器的后退按钮。

Please, read Angular official documentation first. 请先阅读Angular官方文档 Then you'll be able to use Angular Router and define each needed route (url). 然后,您将能够使用Angular Router并定义每个所需的路由(URL)。

Back navigation will be possible with below code : 使用以下代码可以返回导航:

import { Component } from '@angular/core';
import { Location } from '@angular/common';

@Component({
  //...
})
class SomeComponent {
  constructor(private location: Location) {}

  back() {
    this.location.back();
  }
}

As mentioned in this answer . 正如这个答案中提到的。

call the back function again on click og back button of browser. 单击浏览器的后退按钮再次调用后退功能。

window.onbeforeunload = function () {
   this.back();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 防止浏览器后退按钮不转到上一页 - Prevent browser back button to not go to previous page 当我单击浏览器的“后退”按钮时,它应该转到同一页面的上一个活动 - when I clicking on Back button of browser , it should go to the previous activity of the same page 当我单击浏览器中的后退按钮时,我需要将上一页重新加载到“另一个 URL” - I need to reload the previous page to 'another URL' when I click on back button in browser 单击浏览器的“后退”按钮时,返回上一页的上一个位置 - Go Back to the Previous Location on Previous Page when Clicking Browser Back Button 浏览器 go 回到上一页的活动div - Browser go back to active div in previous page 即使更改了哈希值,如何在网页中单击浏览器后退按钮时返回上一页? - How to go back to the previous page when browser back button is clicked in a webpage even when the hash is changed? 当按下浏览器后退按钮(在 Javascript 中)时,如何将特定变量传递给 go 返回上一页? - How to pass a specific variable to go back to the previous page when the browser back button is pressed (In Javascript)? 单击浏览器后退按钮时如何转到当前页面的上一页 - How to go previous page of current page , while clicking browser back button Cakephp 2,返回/取消按钮转到上一页 - Cakephp 2, back/cancel button to go to the previous page 为什么当我返回上一页时,我的网址不正确(iOS下为Chrome,浏览器为后退) - Why when I go back to previous page, I have an incorrect url (Chrome under iOS, browser back)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM