Resize the Facebook iFrame Tab Page with resizing content and different page heights on page loads.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" style="overflow: hidden"> | |
<body style="overflow:hidden"> | |
<head> | |
<!-- You need to include jquery & FBSDK--> | |
</head> | |
<body> | |
<div id="fb-root"></div> | |
<script> | |
window.fbAsyncInit = function() { | |
// The following line is needed to workaround a Facebook bug. See stackoverflow.com/questions/5212016/facebook-javascript-sdk-over-https-loading-non-secure-items) | |
FB._https = window.location.protocol == "https:"; | |
FB.init({ | |
appId : '{{ FACEBOOK_APP_ID }}', | |
channelUrl : "http{% if request.is_secure %}s{% endif %}://{{ request.get_host }}{% url photos-landing %}channel", | |
status : true, | |
cookie : true, | |
xfbml : true, | |
oauth : true | |
}); | |
}; | |
// Load the SDK Asynchronously | |
(function(d) { | |
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} | |
js = d.createElement('script'); js.id = id; js.async = true; | |
js.src = '//connect.facebook.net/{% ifequal LANGUAGE_CODE|slice:"2" "fr" %}fr_CA{% else %}en_US{% endifequal %}/all.js'; | |
d.getElementsByTagName('head')[0].appendChild(js); | |
}(document)); | |
// Resize the iFrame after the whole window is loaded | |
window.onload = function() { | |
var window_height = $('body').outerHeight(); | |
FB.Canvas.setSize({ height: window_height }); | |
}; | |
</script> | |
<!-- PAGE CONTENT --> | |
</body> | |
<html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment