forked from roshansaini18/html01-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
navbar.js
36 lines (29 loc) · 1.01 KB
/
navbar.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
31
32
33
34
35
36
window.addEventListener('scroll', () => {
const nav = document.getElementById('nav');
if (window.scrollY > 50) {
nav.classList.add('scrolled');
} else {
nav.classList.remove('scrolled');
}
});
window.addEventListener('scroll', () => {
const nav2 = document.getElementById('nav2');
if (window.scrollY > 50) {
nav2.classList.add('scrolled');
} else {
nav2.classList.remove('scrolled');
}
});
window.onload = function() {
// Make a GET request to home.html
var xhr = new XMLHttpRequest();
xhr.open('GET', 'navbar.html', true);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
// If request is successful, extract content and insert it into the about.html
var data = xhr.responseText;
document.getElementById('homeContent').innerHTML = data;
}
};
xhr.send();
};