avatar-dance-fever / script.js
VideoSuccess123's picture
How can you do SEO optimization for me
4c7fe36 verified
Raw History Blame Contribute Delete
2.7 kB
document.addEventListener('DOMContentLoaded', function() {
// Mobile menu toggle
const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
const navLinks = document.querySelector('.nav-links');
if (mobileMenuBtn) {
mobileMenuBtn.addEventListener('click', function() {
navLinks.style.display = navLinks.style.display === 'flex' ? 'none' : 'flex';
});
}
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
if (targetId === '#') return;
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 80,
behavior: 'smooth'
});
// Close mobile menu if open
if (navLinks && navLinks.style.display === 'flex') {
navLinks.style.display = 'none';
}
}
});
});
// Form submission
const contactForm = document.querySelector('.contact-form');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
// Track form submission in Google Analytics (if implemented)
if (typeof gtag !== 'undefined') {
gtag('event', 'form_submission', {
'event_category': 'contact',
'event_label': 'Contact Form Submitted'
});
}
// In a real implementation, you would send the form data to a server
alert('Thank you for your message! We will get back to you soon.');
this.reset();
});
}
// Structured data for organization
const structuredData = {
"@context": "https://schema.org",
"@type": "Organization",
"name": "HayShape",
"url": "https://www.hayshape.com",
"logo": "https://www.hayshape.com/images/logo.png",
"description": "Professional web design and development agency",
"sameAs": [
"https://www.facebook.com/hayshape",
"https://www.twitter.com/hayshape",
"https://www.linkedin.com/company/hayshape"
]
};
const script = document.createElement('script');
script.type = "application/ld+json";
script.text = JSON.stringify(structuredData);
document.head.appendChild(script);
});