JSFiddle - React, Tailwind, and code Playground

by Kenneth Luplau-Brøgger

HTML

<button class="hej">
Hej
</button>

<button class="dav">
Dav
</button>

JavaScript

const baseUrl = window.location.href;


window.addEventListener('popstate', (event) => {
	console.log("hejwusa")
  if (event.state && event.state.step) {
    console.log(event.state.step);
  }
});

document.querySelector(".hej").addEventListener("click", () => {

  window.history.pushState({
    step: "hej"
  }, '', baseUrl);
})

document.querySelector(".dav").addEventListener("click", () => {
  window.history.pushState({
    step: "dav"
  }, '', baseUrl);
})