BBog
BBog

Reputation: 3650

Scrolling to the top of a new opened page inside an iframe

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

Upvotes: 1

Views: 3193

Answers (2)

BBog
BBog

Reputation: 3650

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

Upvotes: 1

OptimusCrime
OptimusCrime

Reputation: 14863

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.

Upvotes: 1

Related Questions