diff --git a/js/customElements/newComment.js b/js/customElements/newComment.js
index 0080b3eb98abbfb4abbfbe964096f53b7c29b647..1523128ddbd648cf1b4ce06e00d644dbc36e592e 100644
--- a/js/customElements/newComment.js
+++ b/js/customElements/newComment.js
@@ -14,7 +14,7 @@ class newComment extends HTMLElement {
         script.src = "https://hCaptcha.com/1/api.js";
         script.type = 'text/javascript';
         script.onload = () => {
-            let pageName = path.split("/").pop();
+            let pageName = window.location.pathname.split("/").pop();
             this.parentElement.innerHTML = ` 
                 <form action="/API/newComment.php" method="post">
                     <label for="name">Name:</label><br>