admin管理员组文章数量:1354764
Just as the question states, I have an iframe that is on a cross domain parent. I need to trigger an event if that content is scrolled into view or already in view on page load. Normal checks for distance from top/side of page and viewport height/width don't seem to work as they measure the page within the iframe itself.
I cannot edit/add anything on the parent page to enable this functionality, everything must be within the iframe itself.
The reason behind this is to record whether content has ever had the chance to be viewed by the user or if it was loaded out of view and kept there.
There are panies who provide this service for advertising, but as far as finding out how it is actually done, well it seems to be one of the dark arts.
Any help would be greatly appreciated.
EDIT: Two examples of the panies I spoke of who offer this service.
- View the first tick under (4) /
- First thing they state they can do on the right hand side .page
Just as the question states, I have an iframe that is on a cross domain parent. I need to trigger an event if that content is scrolled into view or already in view on page load. Normal checks for distance from top/side of page and viewport height/width don't seem to work as they measure the page within the iframe itself.
I cannot edit/add anything on the parent page to enable this functionality, everything must be within the iframe itself.
The reason behind this is to record whether content has ever had the chance to be viewed by the user or if it was loaded out of view and kept there.
There are panies who provide this service for advertising, but as far as finding out how it is actually done, well it seems to be one of the dark arts.
Any help would be greatly appreciated.
EDIT: Two examples of the panies I spoke of who offer this service.
- View the first tick under (4) http://www.doubleverify./what-is-verification/
- First thing they state they can do on the right hand side http://adxpose./home.page
4 Answers
Reset to default 5spider.io does this probably using browser timing attacks. there is a video on their page:
http://www.spider.io/viewability/
here is a nice report on how some browser timing attacks work: http://www.contextis./documents/2/Browser_Timing_Attacks.pdf
Simple answer is, you can't.
You have no way to access a cross-domain iframe
(DOM
or window object
) with ECMAscript because of the Same Origin Policy.
Are you sure those examples are exclusively iframe based? Maybe they need to add some javascript to the parent Window.
If you really need this, and 100% accuracy is not needed, I would try some time based techniques on the assumption that most browser will optimize graphical work happening out of view.
Being realistic I don't think it would be possible to get good results with that techniques in a reasonable time or expecting a general robust cross-browser solution. It would be quite fun though.
doubleverify and adxpose use "offline" techniques to determine if the ad was visible or not, it doesn't happen on the page view. If they did it through Javascript, all you would have to do is look at one of their pixels to see how it works.
本文标签:
版权声明:本文标题:javascript - How to detect if an element is visible within an iframe that is on a cross domain parent - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743991945a2572304.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论