Take the 2-minute tour ×

Is it possible to get the referrer of an iFrame's parent page with JavaScript in iFrame?

Example: Page A has an iFrame. The iFrames referrer is be page A. But is is possible to get Page A's referrer in the iFrame with JavaScript?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

This should be:


Anything in the window that creates the iframe should be accessible through the parent scope.

share|improve this answer
They fixed the spelling in the DOM? Cool :) –  Chris May 8 '10 at 2:34
How about is there are multiple iframes inside in each other? –  Norbert Tamas May 8 '10 at 2:44
@Norbert: I would assume parent.parent to refer to a "grandparent' and so on. I haven't tested. I am wondering now what you're actually doing that brought this up. Edit: Just tested and confirmed, this does work as expected. –  Anthony May 8 '10 at 2:47
The easiest way to get the parent (if there are iFrames) referrer in javaScript is: top.document.referrer This works if the iFrame has the same domain as the parent page and works with multiple iFrames. There is no way to get the parent referrer because of cross browser security if the iFrame and the parent has different domains. –  Norbert Tamas May 17 '10 at 16:47
@Norbert: this last comment should be an answer. I would up vote it. :) –  Francisco R Feb 7 '13 at 15:03

Your Answer


