Search code examples
jqueryfacebookiframeheightcolorbox

find the visible height of my iframed page - (fb page)


My page is displayed in an iframe (facebook page) It is around 2000px tall, but of course only a few hundered are visble at any time.

Is it possible to find out the visible hieght of my page? Using $window.width() is giving me the total height of the page.


Solution

  • The facebook javascript sdk has the method FB.Canvas.getPageInfo:

    As a Canvas app runs within an iframe it does not have access to window.innerHeight and window.innerWidth. This method exists to provide access to the client (browser) dimensions as well as the current scroll position and offset coordinates.

    It's easy to use:

    FB.Canvas.getPageInfo(
        function(info) {
            console.log(info);
        }
    );
    

    From that info you should be able to calculate what you need.