Iframe Quiz!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
J0kerz
Forum Commoner
Posts: 37
Joined: Fri May 29, 2009 2:51 pm

Iframe Quiz!

Post by J0kerz »

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 a popup show page C.

What referrer is used for C?
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Iframe Quiz!

Post by McInfo »

C's referrer is B because the link was on B. Opening a page in an iframe or popup is similar to opening it in a new full-sized window or tab. Even though the opened page is presented as part of the triggering page, it is still a separate page.
User avatar
J0kerz
Forum Commoner
Posts: 37
Joined: Fri May 29, 2009 2:51 pm

Re: Iframe Quiz!

Post by J0kerz »

Okay, FF/Opera/Chrome tell me B, but IE8 says A.

What the hell?
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Iframe Quiz!

Post by McInfo »

Internet Explorer 7 says B too.
User avatar
J0kerz
Forum Commoner
Posts: 37
Joined: Fri May 29, 2009 2:51 pm

Re: Iframe Quiz!

Post by J0kerz »

Try IE8.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Iframe Quiz!

Post by McInfo »

I would have to install it; but I'm not going to because I don't want to risk screwing up my system right now.

Try this. If you need a second opinion, maybe someone else with IE8 can run it.

ref.php

Code: Select all

<?php
if (! function_exists('ref')) {
    function ref () {
        if (isset ($_SERVER['HTTP_REFERER'])) {
            return basename($_SERVER['HTTP_REFERER']);
        }
        return 'none';
    }
}
printf('<pre>Referrer: %s</pre>', ref());
a.php

Code: Select all

<?php include 'ref.php'; ?>
<iframe src="b.php"></iframe>
b.php

Code: Select all

<?php include 'ref.php'; ?>
<a href="c.php">c.php</a>
c.php

Code: Select all

<?php include 'ref.php'; ?>
Post Reply