Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有一种方法可以访问网页的一部分是否通过Javascript呈现在屏幕上?_Javascript_Iframe_Gpu - Fatal编程技术网

有没有一种方法可以访问网页的一部分是否通过Javascript呈现在屏幕上?

有没有一种方法可以访问网页的一部分是否通过Javascript呈现在屏幕上?,javascript,iframe,gpu,Javascript,Iframe,Gpu,目前,我们的逻辑在客户端页面上的iframe中运行。我们现在需要检测iFrame当前是否在查看窗口中(滚动到屏幕外) 我只是有一个想法,这可能是GPU可能已经拥有的东西,这将允许它在页面上提供更好的性能,关于它呈现的内容,我想知道是否有人知道这些数据是否可以通过API/lib(如OpenGL)访问 我知道,提供实际的像素信息可能是一个很大的安全问题,但是只要能够访问是否正在渲染特定的iFrame,就有助于可视性检测 有人知道是否有办法做到这一点吗?到目前为止,目前的阅读并没有显示这是可能的,但我

目前,我们的逻辑在客户端页面上的iframe中运行。我们现在需要检测iFrame当前是否在查看窗口中(滚动到屏幕外)

我只是有一个想法,这可能是GPU可能已经拥有的东西,这将允许它在页面上提供更好的性能,关于它呈现的内容,我想知道是否有人知道这些数据是否可以通过API/lib(如OpenGL)访问

我知道,提供实际的像素信息可能是一个很大的安全问题,但是只要能够访问是否正在渲染特定的iFrame,就有助于可视性检测

有人知道是否有办法做到这一点吗?到目前为止,目前的阅读并没有显示这是可能的,但我正在继续我的搜索,我想我也会在这里发布


任何信息或方向都会有帮助。谢谢

您可以计算对象是否在视口中

$(文档).ready(函数(){
myElement=$('.someObject');
window.onscroll=函数(){
var screenTop=$(window.scrollTop();
var screenboth=screenboth+$(窗口).height();
var elTop=$(myElement).offset().top;
var elBottom=elTop+$(myElement).height();
变量信息='screenTop:'+screenTop+'screenBottom:'+screenBottom+'elTop:'+elTop+'elBottom:'+elBottom;
如果((elBottom=屏幕顶部)){
$('.info').html('元素在视图中+'+info+'');
}否则{
$('.info').html('元素不在视图中+'+info+'');
}
}
})

感谢您的回复。不幸的是,当从另一个域在iFrame中工作时,当返回null时,似乎无法访问父窗口元素。这是真的-如果iFrame来自另一个源(域),则无法访问其内容。
$(document).ready(function() {
  myElement = $('.someObject');
  window.onscroll = function() {

    var screenTop = $(window).scrollTop();
    var screenBottom = screenTop + $(window).height();    
    var elTop = $(myElement).offset().top;
    var elBottom = elTop + $(myElement).height();

    var info = 'screenTop:' + screenTop + ' screenBottom:' + screenBottom + ' elTop:' + elTop + ' elBottom:' + elBottom;

    if((elBottom <= screenBottom) && (elTop >= screenTop)) {
      $('.info').html('Element is in view + <small>' + info + '</small>');
    } else {
      $('.info').html('Element is out of view + <small>' + info + '</small>');
    }

  }
})