M
M
Mikhail Lebedev2021-06-27 12:14:30
JavaScript
Mikhail Lebedev, 2021-06-27 12:14:30

How to make the "Go back" button appear/active when a history appears on the page?

There is a button in the menu Back

<a href="#" onclick="history.back();return false;">Вернуться назад</a>

How to make it active only when a story appears on the page (the user made a transition to another page)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2021-06-27
@zaza41rus

<a href="#" class="d-none" id="history-back" onclick="history.back();return false;">Back</a>

window.addEventListener("load", function() {
    if (window.history.length > 1) {
      document.getElementById("history-back").classList.remove("d-none");
    }
  });

.d-none {
  display: none;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question