diff --git a/JAVASCRIPT/1.js b/JAVASCRIPT/1.js index a6fa41a..f15538e 100644 --- a/JAVASCRIPT/1.js +++ b/JAVASCRIPT/1.js @@ -246,10 +246,17 @@ window.addEventListener("scroll", () => { /*when the window is reloading or loading*/ window.addEventListener('load', function() { - const targetElement = document.getElementById('container_1'); - targetElement.scrollIntoView(); - const sidebarCheckbox = document.getElementById('sidebar-active'); - if (sidebarCheckbox.checked) {sidebarCheckbox.checked = false;} + requestAnimationFrame(() => { + const targetElement = document.getElementById('container_1'); + if (targetElement) { + targetElement.scrollIntoView({ behavior: 'smooth', block: 'start' }); + } + }); + + const sidebarCheckbox = document.getElementById('sidebar-active'); + if (sidebarCheckbox && sidebarCheckbox.checked) { + sidebarCheckbox.checked = false; + } });