MediaWiki:Common.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 244:
// === NEW LOGIC START: Scroll to Top for "Contents" ===
// If the user clicks the "Contents" header (id="mw-toc-heading"), scroll to top (0,0)
// === FIXED CODE ===
if (targetId === 'mw-toc-heading') {
closeOverlay();
window.scrollTo({ top: 0, behavior: 'smooth' });
// Delay scroll to let iOS Safari process the overflow change
// Optional: Remove the hash (#) from the URL bar for a clean look
setTimeout(function() {
if (history.replaceState) {
return;try {
history.replaceState(null, '', window.location.pathname + window.location.search);
window.scrollTo({ top: 0, behavior: 'smooth' });
} catch (e) {
window.scrollTo(0, 0);
}
// Fallback for older iOS Safari
return;
document.documentElement.scrollTop = 0;
}
document.body.scrollTop = 0;
}, 100);
if (history.replaceState) {
history.replaceState(null, '', window.location.pathname + window.location.search);
}
return;
}
// === NEW LOGIC END ===