Detect if website is being iframed

Hey there,

I know that in Javascript you can use to check if your website is being iframed but I was wondering if there is anyway to do that in PHP?

I would like to retrieve the url of the website that is iframing me and do something.


If they are using PHP then more likely they’ll just pull your content into their page without using an iframe at all.

You can prevent the page from displaying on domains other than yours by testing if where it is being displayed is your domain or not before allowing the content to be output. That would prevent them actually grabbing your content into their own page but probably wouldn’t stop it appearing in an iframe since there is no way to tell that on the server end.

Not on an initial request, you could however, use JS to check then fire this off via AJAX back to the application.