File size: 1,129 Bytes
3f22380 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
// MCP Website JavaScript
// Highlight active navigation link based on current page
document.addEventListener('DOMContentLoaded', () => {
const currentLocation = window.location.pathname;
const navLinks = document.querySelectorAll('nav a');
navLinks.forEach(link => {
if (link.getAttribute('href') === currentLocation ||
(currentLocation.endsWith('/') && link.getAttribute('href') === '/index.html')) {
link.classList.add('nav-active');
}
});
});
// Mobile navigation toggle (if needed for responsive design)
function toggleMobileNav() {
const nav = document.querySelector('nav ul');
nav.classList.toggle('mobile-nav-active');
}
// Smooth scroll to anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 80, // Adjust for header height
behavior: 'smooth'
});
}
});
});
|