-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
26 lines (23 loc) · 904 Bytes
/
scripts.js
File metadata and controls
26 lines (23 loc) · 904 Bytes
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
// Smooth scroll for navigation links
document.querySelectorAll('nav a').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const href = this.getAttribute('href');
// Check if the href is an internal anchor or an external URL
if (href.startsWith('#')) {
// Internal anchor link
const targetElement = document.querySelector(href);
// Check if the target element exists
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth'
});
} else {
console.warn('Target element not found for href:', href);
}
} else {
// External link (e.g., suggestions.html), just redirect
window.location.href = href;
}
});
});