From bd73e3703ccd7b873dc2a3ff64e1b906889550b2 Mon Sep 17 00:00:00 2001 From: KeshavPathak01 Date: Sat, 2 Aug 2025 19:11:27 +0530 Subject: [PATCH 1/2] Added 404 page --- assets/html_files/page_not_found.html | 64 +++++++++++++++++++++++++++ script.js | 33 ++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 assets/html_files/page_not_found.html diff --git a/assets/html_files/page_not_found.html b/assets/html_files/page_not_found.html new file mode 100644 index 0000000..4675035 --- /dev/null +++ b/assets/html_files/page_not_found.html @@ -0,0 +1,64 @@ + + + + + + 404 - Page Not Found + + + +
+

404

+

Oops! Page Not Found

+

The page you're looking for doesn't exist or has been moved.

+ 🔙 Go Back + Go Home + Contribute on GitHub +
+ + diff --git a/script.js b/script.js index 18cd3e3..77b212a 100644 --- a/script.js +++ b/script.js @@ -180,3 +180,36 @@ const subtitleOptions = { }; const typedSubtitle = new Typed('#animated-text', subtitleOptions); }); + +document.querySelectorAll('a').forEach(anchor => { + anchor.addEventListener('click', function (e) { + const href = this.getAttribute('href'); + + // Ignore external links, hash links, mailto, tel, or javascript:void(0) + if ( + !href || + href.startsWith('http') || + href.startsWith('#') || + href.startsWith('mailto:') || + href.startsWith('tel:') || + href.startsWith('javascript:') + ) return; + + e.preventDefault(); + + fetch(href, { method: 'HEAD' }) // Use HEAD for faster check + .then(response => { + if (!response.ok) { + // If response status is not 2xx + window.location.href = 'page_not_found.html'; + } else { + window.location.href = href; + } + }) + .catch(() => { + // If fetch fails (e.g., network error) + window.location.href = 'page_not_found.html'; + }); + }); +}); + From 1f3f9fb56d5a14a2819ee577854ec5e7f198dbd7 Mon Sep 17 00:00:00 2001 From: KeshavPathak01 Date: Sat, 2 Aug 2025 23:39:10 +0530 Subject: [PATCH 2/2] made responsive 404 page --- assets/html_files/page_not_found.html | 31 ++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/assets/html_files/page_not_found.html b/assets/html_files/page_not_found.html index 4675035..f20af36 100644 --- a/assets/html_files/page_not_found.html +++ b/assets/html_files/page_not_found.html @@ -20,9 +20,10 @@ text-align: center; padding: 20px; } - .container { + /* .container { max-width: 500px; - } + } */ + h1 { font-size: 6rem; color: #ff6b6b; @@ -36,6 +37,12 @@ margin-bottom: 30px; color: #555; } + .anchortag { + display: flex; + gap: 15px; + justify-content: center; + margin-top: 20px; + } a { display: inline-block; margin: 0 10px; @@ -45,10 +52,27 @@ background-color: #007bff; border-radius: 5px; transition: background-color 0.3s ease; + font-size: 1rem; + min-width: 120px; + text-align: center; } a:hover { background-color: #0056b3; } + + @media screen and (max-width: 768px) { + .anchortag { + flex-direction: column; + align-items: center; + gap: 12px; + } + a { + margin: 0; + width: 80%; + font-size: 1.1rem; + padding: 14px 0; + } + } @@ -56,9 +80,10 @@

404

Oops! Page Not Found

The page you're looking for doesn't exist or has been moved.

+ +