prevent page opening on an iframe?

后端 未结 3 1419
青春惊慌失措
青春惊慌失措 2021-01-06 12:20

How can I prevent page opening on an iframe using PHP? Like Gmail inside an iframe?

3条回答
  •  别那么骄傲
    2021-01-06 13:15

    You cannot know from PHP code whether the current page is being loaded inside someone's iframe. PHP is run at the server, before anything is sent to the browser.

    Only JavaScript, which runs in the browser, can detect if its window is the parent or not and do something about it.

提交回复
热议问题