File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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' ) ;
You can’t perform that action at this time.
0 commit comments