Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions assets/html_files/page_not_found.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>404 - Page Not Found</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #f4f4f4;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
text-align: center;
padding: 20px;
}
/* .container {
max-width: 500px;
} */

h1 {
font-size: 6rem;
color: #ff6b6b;
}
h2 {
margin: 20px 0;
font-size: 1.5rem;
color: #333;
}
p {
margin-bottom: 30px;
color: #555;
}
.anchortag {
display: flex;
gap: 15px;
justify-content: center;
margin-top: 20px;
}
a {
display: inline-block;
margin: 0 10px;
text-decoration: none;
padding: 10px 20px;
color: white;
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;
}
}
</style>
</head>
<body>
<div class="container">
<h1>404</h1>
<h2>Oops! Page Not Found</h2>
<p>The page you're looking for doesn't exist or has been moved.</p>
<div class="anchortag">
<a href="javascript:history.back()" class="button">πŸ”™ Go Back</a>
<a href="/index.html">Go Home</a>
<a href="https://github.com/pavitraag/Project-Vault" target="_blank">Contribute on GitHub</a>
</div></div>
</body>
</html>
33 changes: 33 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
});
});
});