0
How to load script only after scroll
I want to load script only after user scroll down to certain position. I tried this jquery method but it is not working. Any idea? Â $( window ).scrollTop(800); Â $.ajax({ Â url: 'https://externalscript.comt/my.js', Â dataType: 'script', Â cache: true, Â Â }); Â });
3 Answers
+ 2
replace alert with the script you want
+ 1
let flag = false; document.onscroll = () => { if (scrollY > 300 && flag == false) {flag = true; alert("reached")}}
https://code.sololearn.com/We0x0YDN9C9N/?ref=app
0
Gordon but how to call javascript