Fixed element inside iFrame

I probably asked this question earlier on the way =) But still, does anyone know if it is possible to have a fixed element inside an iFrame? I mean, do I have a fixed relationship with the entire browser window?

Thanks!

+4
source share
2 answers

No - you cannot display elements inside an iframe outside your borders.

+4
source

Solution for the Facebook iframe application - you have an application in iFrame, when the user scrolls down, the whole page scrolls down, both facebook and iframe:

Using JavaScript, you usually position your fixed element as follows:

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

From inside an iFrame, do the following:

 top = window.parent.pageYOffset + window.parent.height() / 2 - $(id).height() / 2 left = window.width() / 2 - $(id).width() / 2 
+2
source

Source: https://habr.com/ru/post/1345879/


All Articles