Skip to content

Commit 7fed065

Browse files
fix menu
1 parent efe6794 commit 7fed065

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

index.html

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,13 +1769,23 @@ <h3 class="modal-title">Need IT Job or Interview Support? We’re Here to Help!<
17691769
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
17701770
anchor.addEventListener('click', function (e) {
17711771
e.preventDefault();
1772-
const target = document.querySelector(this.getAttribute('href'));
1772+
1773+
const targetId = this.getAttribute('href');
1774+
const target = document.querySelector(targetId);
1775+
17731776
if (target) {
1774-
target.scrollIntoView({
1775-
behavior: 'smooth',
1776-
block: 'start'
1777+
// Offset for sticky navbar
1778+
const yOffset = -90; // adjust based on navbar height
1779+
const y = target.getBoundingClientRect().top + window.pageYOffset + yOffset;
1780+
1781+
window.scrollTo({
1782+
top: y,
1783+
behavior: 'smooth'
17771784
});
17781785

1786+
// Update URL hash 🔥 (THIS FIXES YOUR ISSUE)
1787+
history.pushState(null, '', targetId);
1788+
17791789
// Update active nav link
17801790
document.querySelectorAll('.nav-link').forEach(link => {
17811791
link.classList.remove('active');

0 commit comments

Comments
 (0)