Referrers in iframes

Tuesday 23 December 2008

Yet another in a recent spate of browser discoveries, this one has to do with displaying pages in iframes, and how referrers work with them.

Here's the quiz: suppose page A displays page B in an iframe. What is the referrer for page B? The answer is simple: page A. Now suppose that B contains a link to page C. Click the link, and the iframe now shows page C. What referrer is used for C?

The answer isn't so simple. Turns out Firefox 3 and Safari 3 both report that C's referrer is B, while IE 6 reports that it is A! I don't have IE 7 or 8 at the moment to try.

BTW: all these niggling browser behavior posts are the result of trying to hire a web front-end developer, and me having to help out while we look...

tagged: » 6 reactions

Comments

[gravatar]
mike bayer 5:55 PM on 23 Dec 2008

you hardly see iframes used anymore anyway these days, as ajax-like techniques like element.innerHTML are so much more common (and easy with libs like jquery....)

[gravatar]
Ned Batchelder 5:58 PM on 23 Dec 2008

@mike, that's true. In this case, we're displaying a photo cube editor on a partner's page. Iframes are the simplest way to keep their world and our world separate while providing a seamless experience to the user.

[gravatar]
Al 10:43 PM on 23 Dec 2008

What is equally as frustrating is when another site frames your site (if you allow it) into an intermediate framed page. From memory, this results in your site not seeing a referrer at all.

As an example:

Site A, URL 1 (normal)
Site A, URL 2 (frame, Site B)

From a web statistics stand point, Site B doesn't see a referrer because the user clicked from URL 1 to URL 2. If they start interacting with Site B within the frame, it is completely separate.

[gravatar]
ganool 6:35 PM on 7 Dec 2009

nice info bro..

[gravatar]
Bogdan Ghervan 6:55 AM on 11 May 2010

It is true that you see less of iframes today, but you get a lot of that while developing Facebook apps. Further, iframes are still used as ways to sandbox content for whatever reasons.

[gravatar]
Jim 10:56 AM on 7 Feb 2011

The iframe is still a valid HTML element and should be respected as such (whether widely used or not).

@mike Ajax is another method, and one with its own list of bugs/limitations, not a solution.

This problem also occurs in IE7, still no solution other than passing the parent/desired URL within the query string of the iframe.

Add a comment:

name
email
Ignore this:
not displayed and no spam.
Leave this empty:
www
not searched.
 
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.