I want to allow an iframe to request new data from the server (via ajax), only if the iframe is embedded in particular pages. How can I get the top level domain within an iframe?
At first I was thinking security would be easy, on my server I can simply check the http_referrer
which is a standard thing sent with every HTTP request.
But then I realized this http_referrer is actually the domain of my iframe, not the domain that contains the iframe! So if I embedded my_iframe.com in my_site.com, the http_referrer is my_iframe.com
, which doesn't help me know who is embedding the page.
So now I'm pursuing this alternative.