确保页面仅显示在iframe中

时间:2012-09-15 16:23:44

标签: php javascript html facebook

我有一个页面通过iframe显示为facebook pagetab。如何确保页面按预期显示在iframe中?

2 个答案:

答案 0 :(得分:3)

你的意思是

if(top == self)location.replace(“iframewrapper.html?loc =”+ escape(location.href))

答案 1 :(得分:1)

您无法始终确保这一点,因为您的用户始终可以欺骗浏览器,使其符合您的要求。但你可以试试这个:

if (window!=window.top) { /* In a frame! */ }
else { /* probably reload page and redirect to the page embedding the iframe */ }