OS_world_files / script.js
OM-R-Turing's picture
Upload 8 files
6eb195b verified
Raw
History Blame Contribute Delete
1.27 kB
// Main JavaScript for Personal Blog
document.addEventListener('DOMContentLoaded', function() {
// Navigation highlighting
const currentPage = window.location.pathname.split('/').pop();
const navLinks = document.querySelectorAll('nav a');
navLinks.forEach(link => {
if (link.getAttribute('href') === currentPage) {
link.style.fontWeight = 'bold';
}
});
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Form handling
const contactForm = document.getElementById('contactForm');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
alert('Thank you for your message! I will get back to you soon.');
this.reset();
});
}
// Copyright 2023 Personal Blog. All rights reserved.
});