Page 1 of 1

Check if website is being iframed

Posted: Tue Jun 22, 2010 12:21 pm
by J0kerz
hey there,

I know that in Javascript you can use window.top.location 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.

Thanks!

Re: Check if website is being iframed

Posted: Tue Jun 22, 2010 12:26 pm
by Jade
I don't know of any way to do it in PHP, sorry. Here's the Javascript.

[syntax]
if (top.location != location)
top.location.href = document.location.href;
[/syntax]

Re: Check if website is being iframed

Posted: Tue Jun 22, 2010 12:49 pm
by J0kerz
Any way to do this in PHP?

Re: Check if website is being iframed

Posted: Tue Jun 22, 2010 2:41 pm
by Jade
PHP doesn't have a way to access nested window/iframe information, that's something you have to use Javascript for but you could always pass the information from Javascript back to PHP or run the Javascript by building it in PHP code. There's also Ajax.