I am working on a Facebook App where if the user gets an error popup, the page is supposed to auto-scroll to a certain section (read center) of the page. I have got it working on Firefox, IE, Safari but cannot get it to work on Google Chrome.
Right now I’m using this code :
-
document.getElementById(‘banner’).scrollIntoView(true);
–> works on all the major browsers except Chrome
I have tried all the below functions to get it working on Chrome but no luck:
- 1.window.scrollTo(100,500);
- 2.parent.window.scroll(0,0);
- 3.parent.frames.window.scrollTo(200,300);
- 4.var rowpos = jQuery(‘#banner’).position();
- 5.jQuery(‘#iframe_canvas’).animate({ scrollTop: jQuery(‘#banner’).offset().top }, { duration: ‘slow’, easing:
‘swing’});
Since this is to be made to work on a Facebook App that is by rendered by Facebook in an iframe which is sort of like a sandbox, therefore the outermost parent window has no control of the elements inside the iframe, therefore I am running out of ideas.
I would really appreciate if anyone can drop any pointers to help me solve this issue, its holding up my entire project from being delivered 🙁
Thanks in advance!
Use the FB.Canvas.scrollTo function of the Facebook JS-SDK