mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-10 19:01:13 -04:00
fix(curriculum): fix anchors with hash within iframe to scroll to target element (#59508)
This commit is contained in:
@@ -130,6 +130,15 @@ const createHeader = (id = mainPreviewId) =>
|
||||
if (!href || href[0] !== '#' && !href.match(/^https?:\\/\\//)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
else if (href.match(/^#.+/)) {
|
||||
e.preventDefault();
|
||||
const scrollId = href.substring(1);
|
||||
const scrollElem = document.getElementById(scrollId);
|
||||
|
||||
if (scrollElem) {
|
||||
scrollElem.scrollIntoView();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
document.addEventListener('submit', function(e) {
|
||||
|
||||
Reference in New Issue
Block a user