javascript - Run script upon scroll, but only once -


i'm using introjs on website. people can start tour clicking button, want auto-start when visitors scroll down. made function this, keeps starting tour flipping entire webpage out:

window.onscroll = function() {tourstart()};  function tourstart() {     if (document.body.scrolltop > 50) {         introjs().start(); } } 

how can make run once?

thank in advance!

remove handler when start tour:

function tourstart() {     if (document.body.scrolltop > 50) {         window.onscroll = null;         introjs().start();     } } 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -