I want to fire a popup when the user scrolls to a specific element id from my website.
At the moment I manages to do this, but it works in a loop and I can't stop the function after it was executed one time.
Follows my JS code:
$(window).scroll(function() {
 var executed = false;
  if (!executed){ 
  executed = true;
      var hT = $('#scroll-to').offset().top,
      hH = $('#scroll-to').outerHeight(),
      wH = $(window).height(),
      wS = $(this).scrollTop();
   if (wS > (hT+hH-wH)){
   <!--
     window.setTimeout('window.location="javascript:showSuccessToast();"; ',2000);
     // -->
  }}
  });
I can't understand why the function executes, when "executed" variable becomes true. How can i manage it to fire only one time showsuccessToast ?
 
     
     
     
    