Javascript window events are not working in APIGEE Portals

Hi Team,

I am trying to use window.scroll and window.onload java script event functions in my page but its not responding. I've added below Javascript code in setting portal.

<script>

window.onload = function() { if (document.getElementById('sidenavDeveloper') != null) { window.onscroll = onScroll; } } function onScroll() { var removeActiveClass = function (elements) { for (var i = 0; i < elements.length; ++i) { elements[i].classList.remove('active'); } } var anchors = document.querySelectorAll('.sidenav'); var previousRefElement = null; for (var i = 0; i < anchors.length; ++i) { var activehref = anchors[i].getAttribute('href').substring(1); var currentRefElement = document.getElementById(activehref); var currentRefElementTop = parseInt(currentRefElement.getBoundingClientRect().top) - parseInt(150); if (currentRefElementTop <= 1) { previousRefElement = anchors[i]; if (i == anchors.length - 1) { removeActiveClass(anchors); anchors[i].classList.add("active"); } } else { removeActiveClass(anchors); if(previousRefElement == null) { anchors[0].classList.add("active"); } else { previousRefElement.classList.add("active"); } break; } } } </script>

Could you please advise if I am missing anything ?

0 0 80
0 REPLIES 0