在屏幕中心的iframe中修复元素 [英] Fix an element inside an iframe in the center of the screen

查看:196
本文介绍了在屏幕中心的iframe中修复元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个嵌入在FB的粉丝页面中的iframe,并且我想在屏幕中心显示一个固定框(如对话框)。



我如何做到这一点?



UPDATE



查看Work For Us应用程序:





您可以使用clientHeight,clientWidth,scrollTop和scrollLeft来计算中心位置。


I have an iframe embedded inside a fan page of FB, and I want to show a fixed box (like a dialog box) at the center of the screen.

How can I do that?

UPDATE

Look at Work For Us app:

http://www.facebook.com/DiscoverIntel?ref=nf&sk=app_404596412628

When I click in the green button behind (named "Apply for this position") it always shows the "Thank you" dialog at the center of the screen.

解决方案

I just got the same problem today. The solution is you just need to get scroll position of the viewport from the parent of the iframe which is Facebook URL. So, Facebook has provided JavaScript SDK for it already.

http://developers.facebook.com/docs/reference/javascript/FB.Canvas.getPageInfo/

You can use clientHeight, clientWidth , scrollTop and scrollLeft to calculate the center position.

这篇关于在屏幕中心的iframe中修复元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆