How to identify if a webpage is being loaded inside an iframe or directly into the browser window?

前端 未结 16 2390
攒了一身酷
攒了一身酷 2020-11-22 00:28

I am writing an iframe based facebook app. Now I want to use the same html page to render the normal website as well as the canvas page within facebook. I want to know if I

16条回答
  •  走了就别回头了
    2020-11-22 01:01

    Since you are asking in the context of a facebook app, you might want to consider detecting this at the server when the initial request is made. Facebook will pass along a bunch of querystring data including the fb_sig_user key if it is called from an iframe.

    Since you probably need to check and use this data anyway in your app, use it to determine the the appropriate context to render.

提交回复
热议问题