如何确定HTML5元素何时被查看? [英] How to determine when an HTML5 element has been viewed?

查看:103
本文介绍了如何确定HTML5元素何时被查看?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何HTML5事件与用户是否被查看或滚动到视图是否相关联。

I am wondering if there are any HTML5 events associated with whether or not an element has been viewed or "scrolled into view" by the user.

一个例子可能是一个更长的页面,底部的元素,尚未滚动到用户视图...

An example could be a longer page with elements at the bottom, which has yet to be scrolled into the users view...

我已经看到了jQuery解决方案这个问题,但是我只想知道天气是否可以纯粹是通过使用HTML5事件和JavaScript来实现的。

I have seen jQuery solutions to this problem, however I am only interested in figuring out if weather or not this is achievable purely though the use of HTML5 events and JavaScript.

应该注意的是,我已经看过

It should be noted that I have already had a look at the "onfocus" event, which (from it's official description) seems to only be applicable if the user selects or "clicks" somewhere on or within the element itself.

推荐答案

如上所述,没有事件,但是某人已经写了一个方法来检测一个DOM元素是否真实Visi (标题)。它不需要JQuery。您可能需要检查几个事件的值,如文档加载,滚动或窗口调整大小。

As already mentioned, there is no "event" but someone already wrote a method to "detect if a DOM Element is Truly Visible" (the title). It doesn't require JQuery. You might want to check for the value on several events like the document load, scroll or window resize.

这篇关于如何确定HTML5元素何时被查看?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆