How do I make a web page repeat the content (a block of text) every time a user hits the end of the web page – like with infinite scroll, but with the same content?
Asked
Active
Viewed 3,553 times
0
-
Marquee? and jQuery for detecting scroll from top? – Mr. Alien Sep 01 '13 at 14:23
2 Answers
0
A thread that already answers your question:
Javascript how to detect if browser window is scrolled to the bottom
And to make it infinite you simply append a tag with its content every time the "window-bottom" state is reached.
This could be expressed as such:
window.onscroll = function(ev) {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
// you're at the bottom of the page
var div = document.createElement('div')
div.innerHTML = "your content"
document.body.appendChild(div)
}
}

Community
- 1
- 1

Daniel Varab
- 223
- 1
- 10
-
Is it possible to make the div element of a certain class? I added `div class="repeat_content"` but that doesn't work? – user2509945 Sep 01 '13 at 18:33
-
With the chance of me missunderstanding; you can set the new div to be of a specific class by merely adding: `div.className="repeat_content"` – Daniel Varab Sep 01 '13 at 21:47