Skip to content

Instantly share code, notes, and snippets.

@patbenatar
Created May 10, 2012 17:24
Show Gist options
  • Save patbenatar/2654573 to your computer and use it in GitHub Desktop.
Save patbenatar/2654573 to your computer and use it in GitHub Desktop.
Resizing the frame and body of Facebook apps
$ ->
setFbSize()
$('body').bind('resizeframe', setFbSize)
# If this page has fbcomments on it, we need to set height at an interval
# so we resize when new comments/interactions with that widget happen
if $('.fb-comments').length
setInterval(setFbSize, 100)
$(window).load ->
setFbSize()
setFbSize = ->
h = $('#site_container').outerHeight(true)
# set size of fb canvas
FB.Canvas.setSize
width: 520
height: h
# set size of body
$('body').height(h)
html, body {
width: 520px;
}
body {
overflow: hidden;
}
#site_container {
width: 520px;
}
<body>
<div id="site_container">
<%= yield %>
</div>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment