【问题标题】:Infinite text repeat with infinite scroll on web page [closed]网页上无限滚动的无限文本重复[关闭]
【发布时间】:2013-09-04 17:49:30
【问题描述】:

如何让网页在每次用户点击网页末尾时重复内容(一段文本)——就像无限滚动,但内容相同?

【问题讨论】:

  • 选框?和 jQuery 用于检测从顶部滚动?

标签: html infinite-loop infinite-scroll infinite


【解决方案1】:

已经回答了您的问题的线程:

Javascript how to detect if browser window is scrolled to the bottom

为了使其无限,您只需在每次达到“窗口底部”状态时附加一个带有其内容的标签。

这可以这样表达:

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)
    }
}

【讨论】:

  • 是否可以制作某个类的div元素?我添加了div class="repeat_content",但这不起作用?
  • 有误会的机会;您只需添加以下内容即可将新 div 设置为特定类:div.className="repeat_content"
【解决方案2】:
<marquee>Scrolling text</marquee>

【讨论】:

猜你喜欢
  • 2023-03-18
  • 2013-01-12
  • 1970-01-01
  • 2016-11-25
  • 2014-04-08
  • 2018-05-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多