/    Sign up×
Community /Pin to ProfileBookmark

document.referrer in frames

I have a frameset with two frames, say

the frameset page (frameset.html)
frameA (loaded with frame_a.html)
frameB (loaded with frame_b.html)

and another page, referrer.html.

when I click a link in frame_b.html to load referrer.html into that frame, and check document.referrer in referrer.html, the result is always the same…frameset.html.

The referrer is always defined as the frameset, not the document that was loaded into frameB, where the click originated.

here’s the VERY SIMPLE code that I’m using in referrer.html…

document.write(“this is the javascript referrer: ” + document.referrer);

and that’s it.

So my question is, Is it possible to identify the page loaded into the frame, rather than the name of the actual frameset? If so, how?

Any help you could provide would be greatly appreciated.

Thanks!

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@JonaSep 05.2003 — [font=arial][color=maroon]I'd imagine it would be something like this...[/color][/font]

[font=monospace]

top.frames["frame_name"].document.referrer

[/font]

[font=arial][color=maroon]But it's not a standard object and personally I don't think it should be used. I'd use a server-side language to do it instead, since the only browser (I believe) that supports this unstandard object, is Internet Explorer (IE).[/color][/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@davaugustauthorSep 05.2003 — I'd prefer to do it with PHP, but unfortunately, it returns the same thing, the frameset URL.

I can't put any code on the original frame_b.html page, because the viewer may not necessarily be coming from my my pages, they may be coming from elsewhere. Therein lies the problem.

I'd be open to any suggestions about server side alternatives that may be better than PHP at determining what's going on within the frameset.
Copy linkTweet thisAlerts:
@JonaSep 05.2003 — [font=arial][color=maroon]If using PHP, send the PHP value in to a variable and pass that JavaScript variable to the other frame. So in one frame use PHP get get the referer (of that document), and echo() it into a JavaScript variable, and then send it to the other frame so that both frames know where they are.[/color][/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@davaugustauthorSep 05.2003 — Well, the problem is that for each document within the frameset, regardless of which frame the document is in, php returns the url of the frameset as the referrer, not the document url?
Copy linkTweet thisAlerts:
@JonaSep 05.2003 — [font=arial][color=maroon]Hm... Sorry, I'm at a lose for a solution.[/color][/font]

[b][J]ona[/b]
×

Success!

Help @davaugust spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...