GuaccO's picture
Create a comprehensive and visually appealing landing page that effectively converts visitors into customers. The landing page should include:
64fd428 verified
// Mobile menu toggle
document.getElementById('mobile-menu-button').addEventListener('click', function() {
const menu = document.getElementById('mobile-menu');
if (menu.classList.contains('hidden')) {
menu.classList.remove('hidden');
feather.replace();
} else {
menu.classList.add('hidden');
}
});
// Smooth scroll 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
const mobileMenu = document.getElementById('mobile-menu');
if (!mobileMenu.classList.contains('hidden')) {
mobileMenu.classList.add('hidden');
}
}
});
});
// Form submission handling
const form = document.querySelector('form');
if (form) {
form.addEventListener('submit', function(e) {
e.preventDefault();
const email = document.getElementById('email').value;
// Simple validation
if (email && email.includes('@')) {
// In a real app, you would send this to your backend
alert(`Thanks for your interest! We'll be in touch soon at ${email}`);
form.reset();
} else {
alert('Please enter a valid email address');
}
});
}
// Check for WebP support
function checkWebP() {
const elem = document.createElement('canvas');
if (!!(elem.getContext && elem.getContext('2d'))) {
return elem.toDataURL('image/webp').indexOf('data:image/webp') === 0;
}
return false;
}
if (checkWebP()) {
document.documentElement.classList.add('webp');
} else {
document.documentElement.classList.add('no-webp');
}
// Intersection Observer for animations
const observerOptions = {
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-fadeIn');
observer.unobserve(entry.target);
}
});
}, observerOptions);
document.querySelectorAll('.feature-card, .testimonial-card').forEach(card => {
observer.observe(card);
});