Hofuzz
Hofuzz

Reputation: 469

FB.Canvas.scrollTo Not working inside iframe in Facebook tab page

I would like to have a "go to top" link inside an iFrame tab page in the new Facebook timeline, have tried to use FB.Canvas.scrollTo as follows but not working. Any pointers greated appreciated!

<body style="overflow: hidden">
<div id="fb-root"></div>
<script>
  // Load the SDK Asynchronously
  (function(d){
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));

  // Init the SDK upon load
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'myAppID', 
      channelUrl : 'my_channel.html', 
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });

 document.getElementById('go_to_top').addEventListener('click', function(){
      FB.Canvas.scrollTo(0,0);
    }); 

  <div id="goToTop">
     <img border=0 src ="aPicForClicking.jpg">
  </div>
</body>

Upvotes: 3

Views: 3341

Answers (2)

dan baughman
dan baughman

Reputation: 1

Canvas do not throw an error but also do not function when the iframe is within the content of another iframe.

IE. nested iframes are not supported for API calls.

Upvotes: 0

vpascoal
vpascoal

Reputation: 278

I was having the same problem. In the application settings set Canvas Height to Fixed.
Then FB.Canvas.scrollTo(0,0) works fine;

Upvotes: 7

Related Questions