简体   繁体   中英

Accessing parent window from facebook iframe

I'm trying to access in jQuery to the browser width from an iframe inside facebook (app).

The issue is we're not allowed to access to a parent element of an iframe, so I'm trying to get it from a $.post() query where jQuery writes the window with, but since it's a HTTP query, there's no window parameter loaded.

So I'm wondering if we can access to the screen parameter. I mean by this, if there is any browser parameter by default, so I can resize my body page.

For example, if parent.window.width < 500 , I want my body width to be set as 500 .

Thanks for helping me, I appreciate !

The iFrame domain must match the parent domain to be able to access it directly.

If I remember correctly, Facebook offer a "Fluid" option for the canvas size (which sets the iFrame width to 100%). If Facebook still offer this, you could place your content in a container div and add onLoad and onResize events with jQuery in the iFrame document. You could then set the size of the container based on the iFrame document size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM