Erik Lydecker
Erik Lydecker

Reputation: 717

Fixed element inside iFrame

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!

Upvotes: 4

Views: 4097

Answers (2)

user270576
user270576

Reputation: 997

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

Upvotes: 2

DNR
DNR

Reputation: 986

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

Upvotes: 4

Related Questions