Foolproof way to detect if this page is INSIDE a cross-domain iframe

后端 未结 8 1085
梦如初夏
梦如初夏 2020-12-05 13:37

An answer to \"Foolproof way to detect if iframe is cross domain\" describes a method to test if an iframe on a page points to a same-domain or cross-domain page, working ar

8条回答
  •  时光取名叫无心
    2020-12-05 14:13

    If I see your use case:

    I would check it server side (who called your site), using $_SERVER['REMOTE_ADDR'], and if it is your IP than you can hide branding and links backs.

    If the use case is about to prevent framing your site you can use X-Frame-Options: deny.

    Other guess: Elements inside a document have a ownerDocument property, maybe that can help detecting what you want.

提交回复
热议问题