Skip to content

Commit

Permalink
#2025 javascript console errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kkrug committed Sep 19, 2024
1 parent b7821f8 commit 175e82b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,19 @@
{% endif %}
<script>
// Explore challenges button scroll to active challenges section of react app
document.getElementById("js-explore-challenges").addEventListener("click", function(e) {
var scrollTarget = document.getElementById(e.target.getAttribute("data-anchor"))
scrollTarget.scrollIntoView()
})
var exploreChallengesElement = document.getElementById("js-explore-challenges");

if (exploreChallengesElement) {
exploreChallengesElement.addEventListener("click", function(e) {
var scrollTarget = document.getElementById(e.target.getAttribute("data-anchor"));
if (scrollTarget) {
scrollTarget.scrollIntoView();
} else {
console.error("Scroll target not found.");
}
});
}

// Footer archived challenges link to scroll to top of page
document.getElementById("js-archived-challenges").addEventListener("click", function(e) {
window.scrollTo(0,0)
Expand Down

0 comments on commit 175e82b

Please sign in to comment.