From: Ardis Lu Date: Sat, 8 Oct 2022 01:51:18 +0000 (-0700) Subject: Use event listener instead of attribute X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=575fb85be86f2962ea48da0d4f1da0b1e1712b4e;p=minimal-routing Use event listener instead of attribute --- diff --git a/index.html b/index.html index 11a9238..bd6b8d1 100644 --- a/index.html +++ b/index.html @@ -164,7 +164,7 @@ route(e.target.dataset.route); }); } - window.onpopstate = _ => showPage(window.location.pathname.substring(1)); + window.addEventListener('popstate', _ => showPage(window.location.pathname.substring(1))); // Show the current URL (to support direct linking aka deep links) showPage(window.location.pathname.substring(1));