FB setAutoResize 不适用于 FF
好的,所以我一直在开发一个 FB 应用程序,它可以改变每个页面的高度。我显然在我的应用程序布局中使用了 setAutoResize 函数,并且我有以下内容:
window.fbAsyncInit = function() {
FB.init({appId: '###', status: true, cookie: true, xfbml: true});
FB.Canvas.setAutoResize();
};
它在 IE、Safari 和 Chrome 中工作正常,但在 FF4 中不行。我也用过:
window.setTimeout(function() {
FB.Canvas.setSize({height: $('body').height()});
}, 1000);
但也没有运气。以前有人经历过这个吗?提前tnx。 标记
OK, so i've been working on an FB app that changes height on every page. I, obviously used the setAutoResize function in my app layout and i have the following:
window.fbAsyncInit = function() {
FB.init({appId: '###', status: true, cookie: true, xfbml: true});
FB.Canvas.setAutoResize();
};
And it works fine in IE, Safari and Chrome but not in FF4. I also used:
window.setTimeout(function() {
FB.Canvas.setSize({height: $('body').height()});
}, 1000);
but no luck either. Does anyone experienced this before? tnx in advance.
Mark
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
已经提供了答案,但我不妨发布我的问题解决方案。在 Firefox 中,即使您的页面适合,滚动条仍然是 iFrame 的一部分。他们只是没有蓝色滚动条。这增加了大约 20px。
我不认为你的 jQuery 解决方案会起作用,因为 height() 没有考虑边距和填充。也许试试这个。
An answer has already been provided, but I might as well post my solution to the problem. In Firefox the scrollbars are still part of the iFrame even if your page fits. They just don't have the blue scroller. This adds about 20px.
I don't think that your jQuery solution will work because height() doesn't take into account margin and padding. Maybe try this.
我将其添加到我的 css 中,它似乎可以工作(不必破坏我的自动调整大小):
如果您已经在身体顶部添加了填充,则可能需要为其添加 20px。
我认为这是因为 Firefox 测量身体高度的方式与其他浏览器不同。
在 ff8、chrome16 和 ie9 中测试,没有负面影响。
I added this to my css and it seemed to work (didn't have to muck with my autoresize):
If you already have padding added to the top of your body, you will likely need to add 20px to it.
I assume it's because firefox measures the body height differently than other browsers.
Tested in ff8, chrome16 and ie9 with no negative repercussions.
这听起来可能是一个错误?查看:
http://bugs.developers.facebook.net/show_bug.cgi?id=10889
如果这影响了你,请投票:)
This sounds like it might be a bug? Check out:
http://bugs.developers.facebook.net/show_bug.cgi?id=10889
If this is affecting you vote it up :)
仅供参考!根据 Facebook 开发者路线图
FB.Canvas .setAutoResize
将于 2012 年 7 月 5 日重命名为FB.Canvas.setAutoGrow
。从页面:
FYI Warning! According to the Facebook Developer Roadmap
FB.Canvas.setAutoResize
will be renamed toFB.Canvas.setAutoGrow
on July 5, 2012.From the page: