From: Ardis Lu Date: Fri, 30 Sep 2022 04:10:35 +0000 (-0700) Subject: Replace buttons with anchors X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=3fc47f0d17a22748e92a3b5ba8329edbc5e10403;p=minimal-routing Replace buttons with anchors More semantically accurate and allows link preview on hover --- diff --git a/index.html b/index.html index 8882e6a..d4cf2cb 100644 --- a/index.html +++ b/index.html @@ -10,10 +10,10 @@
- - - - + Go to the home page + Go to page 1 + Go to page 2 + Go to page 3
@@ -75,7 +75,10 @@ // Set event handlers for (const router of routers) { - router.addEventListener('click', e => route(e.target.dataset.route)); + router.addEventListener('click', e => { + e.preventDefault(); + route(e.target.dataset.route) + }); } window.onpopstate = _ => showPage(window.location.pathname.substring(1));