-
Notifications
You must be signed in to change notification settings - Fork 0
/
scriptproteg1.js
30 lines (29 loc) · 911 Bytes
/
scriptproteg1.js
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
// // Add smooth scrolling to all links
// $('a').on('click', function(event) {
// if (this.hash !== '') {
// event.preventDefault();
// var hash = this.hash;
// $('html, body').animate({
// scrollTop: $(hash).offset().top
// }, 800, function(){
// window.location.hash = hash;
// });
// }
// });
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
target.scrollIntoView({
behavior: 'smooth'
});
});
});
});
try {
// Code that may throw an error
} catch (error) {
// Handle the error here
console.error('An error occurred:', error);
}