最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Fixed element inside iFrame - Stack Overflow

programmeradmin3浏览0评论

I probably asked this question before in a way =) But still, does anyone know if it's possible to have a fixed element inside an iFrame? I mean fixed i relation to the whole browser window?

Thank you!

I probably asked this question before in a way =) But still, does anyone know if it's possible to have a fixed element inside an iFrame? I mean fixed i relation to the whole browser window?

Thank you!

Share edited Mar 31, 2011 at 11:22 Erik Lydecker asked Mar 30, 2011 at 13:09 Erik LydeckerErik Lydecker 7173 gold badges12 silver badges29 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

No - you cannot display items within an iframe outside of its boundaries.

Solution for "Facebook app iframe" - you have your app in a an iFrame, when the user scrolls down, the whole page is scrolling down, both facebook and the iframe:

Using JavaScript normally you would position your fixed element like so:

top = window.height() / 2 - $(id).height() / 2
left = window.width() / 2 - $(id).width() / 2

From within iFrame do this:

top = window.parent.pageYOffset + window.parent.height() / 2 - $(id).height() / 2
left = window.width() / 2 - $(id).width() / 2
发布评论

评论列表(0)

  1. 暂无评论