Last week I wrote about how to create a custom Facebook page tab with iframes and said I would discuss the scrollbar issue this week.
The default size for a Facebook tab created with iframes is 520px by 800px. If your page is larger than this, there will be ugly scrollbars on the page.
When creating the iframe application, make sure that you selected the following on the Facebook Integration section:
- Canvas Type – select, you guessed it, iframe.
- Iframe size – select auto-resize
Before the ending <body> tag on the html page you created for your iframe, place the following piece of code.
<div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script> FB.init({ appId : '142315715832254', status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); window.fbAsyncInit = function() { FB.Canvas.setAutoResize(); } </script>
Make sure you change the appID to the ID for the application that you created. You can find that by going to Facebook Developers and clicking on the name of the app in the list of applications on the right side of the page. If it’s the only one you have made, it will be the only one listed. I’ve made quite a few so I have a number of them in my list.
Before the </head> tag on your page, add the following:
<script type="text/javascript"> window.fbAsyncInit = function() { FB.Canvas.setSize(); } // Do things that will sometimes call sizeChangeCallback() function sizeChangeCallback() { FB.Canvas.setSize(); } </script>
This pieces of code will solve the scrollbar issues and adjust the frame to size of your page.
If you are still having a scrollbar issue with your iframe page in Internet Explorer, add the following after the <head> tag:
<style type="text/css"> body { width:520px; margin:0; padding:0; border:0; } </style>
There are a couple of serious bugs related to iframe pages that Facebook says they are working on. I will be discussing these in my next post.
Special thanks to Hyperarts – I figured out the first part of this code but they provided the 2nd part, which was a lingering issue for me.
Tutorial: Add an iFrame Application to your Facebook Fan Page – 2011 Edition
Facebook iFrame Apps – Getting Rid of Those Scrollbars
photo credit: psigrist
Andrew @ Blogging Guide says
Great tutorial. It would really be great to be able to get rid of those scrollbars.
Kim Woodbridge says
Hi Andrew – Yep – they sure are ugly.
Luke says
Hm… I’ve tried this (and a ton of other things) but I cannot get rid of the scrollbars… If I use firebug and set the overflow of my tag to hidden, then remove it, it works… obviously this isn’t the best thing in the world… I suppose I could duplicate via jQuery, but that seems messy… any ideas what could cause that?
Kim Woodbridge says
Hi Luke – Is it the vertical, horizontal or both? I had trouble with the horizontal one – there was an element on my page that was over 520px. And have you looked at the articles at hyperarts? There is great information there – in the articles and in the comments.
Tammy says
Same here… have tried this and other things but nothing seems to get rid of those ugly scroll bars… could it be a FB bug?
Ajith Edassery says
Kim,
You are really living upto the facebook and wordpress consultant tag :) So many facebook tips, especially useful when FB itself is evolving faster. Are you getting good contracts on FB page development, branding etc?
Good luck,
Ajith
Kim Woodbridge says
Hi Ajith – Some – it’s maybe 15% of my business right now. Facebook made a lot of changes recently and I’ve decided to write up what I’ve learned.
Tammy says
Going crazy with this.
In integration changed to iFrame and auto-resize.
Changed W & H to 520 X 800 px = framesetsize(520,800)
Still, scroll bars are showing!
Any ideas?
Would truly appreciate them :)
Kim Woodbridge says
Hi Tammy,
You shouldn’t have to set the height – just the width. Have you looked at it in other browsers to see if there are still scrollbars?
I had trouble with the horizontal one because I had an element on the page that was going over. Try pulling parts out piece by piece to see if you can locate the cause of the problem.
francis says
hey, you are SO useful. we may have some contract work for you. Can you email me?
Graham Davidson says
You total legend you have just made me look ace – with removal of those pesky scroll bars.
Tom Buchanan says
I am having a problem with Facebook displaying horizontal and vertical scrollbars on my iFrame.
What’s worse, if you take a look at: http://www.facebook.com/statesidedata
you’ll also see that the canvas URL is replicating the Facebook banner and the Facebook right column. It looks horrible but I can’t seem to fix it.
I have a feeling that my background image is wider than 520px. If true, would the scrollbars and the replicated images be a result of that?
Tom
Tom Buchanan says
Check that URL, it is:
http://www.facebook.com/statesidedatainc
Sorry.
Kim Woodbridge says
Hi Tom,
It looks like the replication of the Facebook banner and right column is what is causing the problem. Your own content seems to fit within the 520px. I think you should double-check your application settings – there might be a setting that is causing this problem.
http://www.kimwoodbridge.com/how-to-make-a-custom-facebook-page-tab-with-iframes/
Tom Buchanan says
Kim,
I really appreciate your taking a look and responding.
In fact, I have checked, checked again and checked I don’t know how many times. I have changed one item at a time and done so multiple times. Isn’t that what they say is the definition of insanity?
Anyway, I’m stumped. I suppose I could try creating a new app, but I’d still be using the same content and the same settings, so it’s hard to see where that would make a difference.
The other option would be to use an entirely different flash from a different author.
Well, I’ve sent an email to the author of the flash and am waiting for a reply. Perhaps he will get back to me one day.
Thanks again,
Tom
Kim Woodbridge says
Hi Tom – You could also try removing each part of the page you made piece by piece. For example, does it work if you remove the flash part of it? When I am having an issue that is how I determine which part of the page is causing the problem.
Tom Buchanan says
Kim,
It’s working now. The tab setting in FB was wrong. What’s really strange is that the incorrect setting ever worked at all, given that it was an invalid URL.
Check it out. I think it looks good.
Thanks.
Tom
Kim Woodbridge says
Hi Tom – I’m glad you got it sorted out.
Clive says
Does this work with WordPress? If so which php files need editing?
Many thanks,
Clive
Kim Woodbridge says
WordPress can be used to create a custom iframe tab. Here is a tutorial
http://www.headwayvideos.com/wordpress-pages/how-to-use-wordpress-to-create-a-custom-facebook-tab
Keith Heustis says
Has anyone had problems getting this to work in Firefox? I’ve got this working in all browsers (even IE 7-9) but Firefox still shows the scroll bars. It’s interesting because Firefox is adding scroll bars in version 4 on the mac and in version 3 on a PC.
Thanks in advance for any help or guidance!
Kim Woodbridge says
Hi Keith – I’m not having problems with Firefox but have not tested version 4 or tested it on the mac. Often, when that happens, there is an element on the page that is pushing past the 520px. I usually remove the code section by section to find what is causing it.
Trisha says
Kim, you always seem to save my hiney when things are looking desperate. There are dozens of tutorials out there showing how to remove the scrollbars. This IS the only one that works. I left my appID blank and it still works. You are a goddess! thanks for sharing all your best stuff.
a true fan for life.
Kim Woodbridge says
Hi Trisha – Great! I’m so glad it worked for.
Nate says
Kim,
How does this work in comparison to some of the articles I have read that requires a script specification for width and height?
Your fix works (although I had to refresh Firefox several times to get the scroll bars to disappear), but I am searching for the theory!!!
Thanks for the post!
Kim Woodbridge says
Hi Nate – I don’t know. I tried a couple of solutions and this one works consistently for me. Although I do sometimes get the refresh to make the scrollbar go away problem.
Sudeep says
Hello,
I have tried many option to discount the scroll bars but it is just not want to go.
I have tried your code but still not worked even I reduced my application size to 500 pixel width size.
Here is my application page: http://www.facebook.com/pages/E-ZONE-CLUB-PVT-LTD/370669591525?sk=app_164540113605232
Note: Still i have not purchased the SSL for my domain
Your help and suggestion appreciated
Thanks and regards,
Sudeep
Kim Woodbridge says
Something on the page is making it go over the max width. When that happens to me I usually sections of code piece by piece until I figure out what is causing the problem.
Sudeep says
Dear Kim,
I figured it out, my header div was eating my space out. Thank you for your help.
Kim Woodbridge says
Great! I’m glad it’s been resolved.
Mark says
Thanks Kim! It’s wonderful to have such a clear, concise explanation of the solution :-) You rock!
Mark
Kim Woodbridge says
Hi Mark – I’m glad the article helped – thanks!
Thomas says
Hi there,
My app was using your trick and it worked perfectly during 2 weeks until… yesterday. Now the app height is again being cut off. I guess something is broken on Facebook JS API right now.
Can you confirm that you guys experience the same problem right now?
Thanks!
Kim Woodbridge says
Hi Thomas – I haven’t had this problem on any of the pages that I work on.
Victoria says
Thaaank you!!! I looked all over the internet for a solution that removes the scrollbars and you gave it to me! Million thanks again! IT definitely worked for me :D
Kim Woodbridge says
Hi Victoria – Great! I’m glad it worked.
Etienne says
Hi,
I confirm Thomas,
The test is simple :
put a simple image of 520 px of width. Nothing else.
You will have the horizontal scroll bar.
The script is not dealing with this issue.
The css tip do nothing.
Set your image to 512 px, you get no more scrollbar.
What is causing 8 px with a simple html page and an image in it ???
Kim Woodbridge says
Are there any margins set? That would happen if there is a 8px margin.
Pavel Langweil says
You’ll have to set css of your to padding:0, margin:0 (facebook puts some padding/margin there I guess), otherwise you won’t have 520px but just something like 512px…
Jared says
IF you find that the instructions above are not doing the trick, you should also add style=”overflow: hidden” to your html and body tags.
Kim Woodbridge says
Hi Jared – Thanks!
Andy says
Hi Kim,
thanks for this. I followed it and it doesn’t work for Firefox on a mac – and your own facebook app shows scrollbars with Firefox on a mac, too.
If anyone had a solution for macs it would be sooooo useful (for me and about 50,000 other people). Firefox is usually the least problematic browser for me
Andy says
Update! I got it to work without scrollbars on a mac in Firefox.
The trick for me was to use WordPress as the CMS, and use the plugin called Facebook Tabs Manager – no extra code required.
If anyone needs any more help, just contact me at Pagetopia.com
Thanks, Kim
Kim Woodbridge says
Hi Andy,
Thanks for the info – I don’t want to pull in a WordPress page so I’ll see if I can locate a solution for the scrollbar issue on the MAC.
Tim says
Just a tip, because this is the first page on Google for this problem:
The FB JS SDK appends code the fb-root DIV when it loads. This code contains an absolute positioned DIV that contains an IFRAME with a styled width of 575px
Try adding the following to your CSS
#fb-root { display: none; }
if you are having problems with a horizontal scrollbar showing about 50px to the right of your content.
Tim.
Michael Tunnell says
Thank you very much for this…this came in handy when I was making my app today although it may have been a waste of time considering the SSL requirement of the Canvas URLs starting on October 1. Oh well.
Kim Woodbridge says
There are solutions for the SSL requirements that I will be writing about soon.
Michael Tunnell says
I’ve actually already hacked my app to comply with the ssl requirement without having to get a bunch of certificates. (multiple sites = multiple apps & domains)
The only problem with it is now the scrollbars fix has stopped working but I am working on it now.
Michael Tunnell says
ok I’ve figured out how to remove the scrollbars on my hack but because it is a hack I lose some functionality and mostly is the height of the FB iframe has to be controlled manually now instead of autosizing. So it works and is compliant with the ssl requirement but it does have drawbacks so looking forward to seeing your solution.
Kim Woodbridge says
Are you going to be posting how you made it work? I would really like to see it.
Michael Tunnell says
I wasn’t planning on it because it does utilize a ssl I already have and it certainly isn’t elegant at all but screw it…if it helps anyone then great.
I’ll edit or reply to this comment once I have the code laid out nice and neat. :)
Michael Tunnell says
How to use an SSL Shell to validate non-secure Facebook iFrame Apps – http://michaeltunnell.com/blog/11-tutorials/8-how-to-use-an-ssl-shell-to-validate-non-secure-facebook-iframe-apps
Kim Woodbridge says
Thanks! Hopefully I will have time later or tomorrow to take a look.
Tania says
Hi there,
I don’t mind having the vertical scrollbar there.
However does anyone know how I can set the CSS so that
the scrollbar background isn’t white (but black to match the
Wordpress theme).
I want to use
scrollbar-base-color: black;
however I can’t get what element I should apply this to.
Any suggestions would be GREATLY appreciated.
Tania
Michael Tunnell says
Tania, sorry but changing the color settings of scrollbars only works on Internet Explorer…all other browsers ignore those settings.
That code goes in the body {} portion of the CSS but like I said it only works on IE because only IE has hideous scrollbar design…all other browsers use very customized scrollbars so it isn’t possible to adjust their colors and depending on the theme and the operating system the visitor is using the scrollbars could be different from the default scrollbars anyway.
This is why for Facebook Apps the solution is to remove them entirely.
Vajaah says
I have used your tutorial on how to create the fb iframe app & remove the scroll bars. Thanks a lot — truly great tutorials!
All was well until things got secured. I do have a SSL, so I won’t need to hack around that but when I add the code to remove the scroll bars, I get warnings in IE about the security of my page. Any suggestions?
Also I noticed that the process to create the iframe app has changed and that now you can just create a “Page Tab” app.
Vajaah says
Quick fix I suppose, I updated the code (before ) in this post to:
window.fbAsyncInit = function() {
FB.init({
appId : 'YOURAPPID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
oauth : true // enable OAuth 2.0
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "https://connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
window.fbAsyncInit = function() {
FB.Canvas.setAutoResize();
}
It works. When I look at the app iframe source it still forces a security alert but when it loads w/in FB it does not.
Kim Woodbridge says
Thanks! That is really helpful.
Steve says
The fact is this code doesn’t work. So I ask — what are you using to get the pages you’ve built to work to display at 520 pixels width not 512?
Vajaah says
@Steve
The code might not work as is, since the latest round of FB changes but with some tweaking it definitely does the trick. I can’t quite document the changes that I made by the time that I finished the Page Tabs, but just as a note of encouragement, it CAN work. I used this post as my foundation to remove the scrollbars.
Here are a few of page tab examples w/ it in action:
https://www.facebook.com/pages/Manassas-Chorale/116265852717?sk=app_278321385525102
https://www.facebook.com/badtothebonesmokehouse?sk=app_230536250293231
https://www.facebook.com/pages/Okras-Cajun-Creole/224948387522715?sk=app_160240160705495
These pages use a mix of images and background images that are 520px (not 512px) and there isn’t a scrollbar (vertical or horizontal).
Kim Woodbridge says
Try heading this to the top of the page.
<html xmlns=”http://www.w3.org/1999/xhtml” style=”overflow: hidden”>
MichaelTunnell.com says
I am using the code provided here with my ssl shell and it displays content over 520px because I am really turning one fullsize site into a smaller facebook ready site while keep all of the same content and such. I have no problem with removing the scrollbars in using the code here.
phil norton says
Works for me…however I still have a vertical scroll bar in Firefox although its not active because now my page fits. Its fine in IE and Chrome, advice would be greatly appreciated as Ive spent days looking for a solution
link to my page
http://www.facebook.com/pages/Kwik-Tan-Stockport/186103111427953?sk=app_283486548360806
Kim Woodbridge says
Hi Phil – Try adding to overflow:hidden; to the style for the page.
Rajesh says
Hey , really great… its help me a lot to fix the issue in IE….. thanks…
Tommaso says
Hello!
I found your link whilst searching how to remove scrollbars in Facebook Tabs.
Just wanted to point out the new function is “FB.Canvas.setAutoGrow” and not “FB.Canvas.setAutoResize”.
In canse somebody else has my problem and finds this blog here is the URL to Facebook Developers Documentation about the function
https://developers.facebook.com/docs/reference/javascript/FB.Canvas.setAutoGrow/
Cheers!