-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinclude.js
More file actions
34 lines (33 loc) · 1.67 KB
/
include.js
File metadata and controls
34 lines (33 loc) · 1.67 KB
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
document.addEventListener('DOMContentLoaded', () => {
// Funzione per includere il footer
function includeFooter() {
fetch('footer.html') // Richiede il contenuto di footer.html
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.text();
})
.then(html => {
const footerPlaceholder = document.getElementById('footer-placeholder');
if (footerPlaceholder) {
footerPlaceholder.innerHTML = html;
} else {
// Se non trovi il placeholder, potresti volerlo aggiungere direttamente al body
// (anche se è meglio avere un placeholder esplicito)
console.warn('Placeholder element with id "footer-placeholder" not found. Appending footer to body.');
document.body.insertAdjacentHTML('beforeend', html);
}
})
.catch(error => {
console.error('Error loading footer:', error);
// In caso di errore, potresti voler aggiungere un footer di fallback
const footerPlaceholder = document.getElementById('footer-placeholder');
if (footerPlaceholder) {
footerPlaceholder.innerHTML = '<footer class="site-footer"><div class="container"><p>© 2024 LaxMap. All rights reserved. <a href="donate.html">Donate</a></p></div></footer>';
}
});
}
// Chiama la funzione per includere il footer
includeFooter();
});