问题
I have an iframe facebook app currently running on a page tab. Unfortunately, when people share some of the links within the page, the resulting shared links send users to the original content on the server and not to the facebook page tab. How can I force users who arrive directly at the URL into the page tab iframe?
回答1:
I found the solution: basically you can use the facebook javascript api to detect if you are within the iframe. If not, redirect. Here is the code:
// Test if canvas page loaded
var obj = FB.Canvas.getPageInfo();
// Now redirect to page if not
if(obj.clientHeight == 0) window.location = 'http://facebook/page/url/';
来源:https://stackoverflow.com/questions/6076359/force-facebook-app-to-use-page-tab-iframe