document.querySelectorAll('a[href*="#contact-section"]').forEach(function(anchor) { anchor.addEventListener('click', function(e) { e.preventDefault(); // Check if #contact-section exists on the current page var contactSection = document.querySelector('#contact-section'); if (contactSection) { contactSection.scrollIntoView({ behavior: 'smooth' }); } }); });