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 Réponses
+ 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