1

I have a facebook app run inside an iframe. The problem is that if I have a smaller browser window, I scroll to the bottom to the app's page list and select a new page, it will open in the iframe also in the bottom.

I tried to add a #top to the links, linking to a name="#top" element inside the new page, but this doesn't work on Firefox (verified) and supposedly IE(not verified yet). For Firefox, I understood it's a known issue and there are some workarounds to make a "scroll to top" link work, BUT I haven't found any solutions on how to open a new link inside the iframe and make it scroll.

I added a onload="location.href='#'" to the body element of the iframe and still no success. Whatever I try, it seems to be ignored by Firefox.

Did any of you encountered this problem before? If so, can you spare some advices, please?

Thanks

Hüseyin Cevizci
  • 919
  • 4
  • 17
BBog
  • 3,630
  • 5
  • 33
  • 64

2 Answers2

1

You could try a "ugly" workaround using http://api.jquery.com/scrollTop/

As a Facebook-developers, I am curious. How do you resize the app-iFrame during runtime? I have a few ajax-based apps, and after every ajax-call I resize the window, eliminating this problem.

Might worth taking a look into.

OptimusCrime
  • 14,662
  • 13
  • 58
  • 96
  • I use the standard Facebook resizing, FB.Canvas.setAutoResize(), plus some small workarounds. I do not use ajax (in a way), but I do make an extensive use of jQuery. I will try to see if your suggestion works, thanks for the tip – BBog Dec 08 '11 at 08:03
  • Unfortunately, it doesn't work, as well as many other solutions I tried: onload="window.parent.scroll(0,0);", document.getElementById("someTopDivId").scrollIntoView();, $(window/html/body).scrollTop(0);... Nothing seems to work with the Facebook iframe combination :( – BBog Dec 08 '11 at 09:40
1

Feels weird to answer my own question, but hopefully this will help others. In the end, what did the trick for me was Facebook's scrollTo function: http://developers.facebook.com/docs/reference/javascript/FB.Canvas.scrollTo/

I still don't know if it works on IE, since I haven't tested it yet, but on Firefox everything is ok now

BBog
  • 3,630
  • 5
  • 33
  • 64