const nav = document.querySelector("nav"); const nav_links = nav.querySelectorAll("ul li a"); const theme_toggle = nav.querySelector("button"); const back = document.querySelector("#backButton"); const links = document.querySelectorAll(".fillDiv"); if (back) back.addEventListener("click", () => { console.log("back"); history.back(); }); links.forEach((el) => { el.addEventListener("click", () => { el.preventDefault(); applyTransition(el.getAttribute("href")); }); }); nav_links.forEach((el) => { el.addEventListener("click", () => { el.preventDefault(); applyTransition(el.getAttribute("href")); }); }); function applyTransition(href) { if ("startViewTransition" in document) { document.startViewTransition(() => { window.location.href = href; }); } else { window.location.href = href; } }