PDA

View Full Version : retrieve frame location's value



ShMiL
Nov 23rd, 2006, 03:43 PM
I have a page with two frames:
A is constant
and B is not

A stays all the times, while the user surfs in B frame.

Is it possible to retrieve B's location?

I need it because I want to save it to DB and 'remember' the last page the user have been to.

when i try this in A frame:

alert(top.frames['body'].location.href);


I get:

Premission Denied

Is it possible to do this?

Thanks

cyber11
Nov 23rd, 2006, 05:48 PM
You are using an incorrect reference to the frame.

Here are 2 that work:
alert(parent.frames[1].location.href);
alert(parent.right_frame.location.href);

use frames[index number]which is an array of frames starting with 0
or use name of frame

ShMiL
Nov 24th, 2006, 09:28 AM
still:

Premission Denied

any idea?

cyber11
Nov 24th, 2006, 11:14 AM
I got no such error.

Can you post your code or an url?

ShMiL
Nov 24th, 2006, 11:30 AM
here it is:
run default.htm

cyber11
Nov 24th, 2006, 11:59 AM
I thought it was propbably a security feature. Which is what it turns out to be.
Read this:
http://msdn.microsoft.com/workshop/author/om/xframe_scripting_security.asp

You can however read it if its a file in the same directory as the current page.
Add an HTML file and set it as the src for the frame to see what I mean.

ShMiL
Nov 24th, 2006, 12:13 PM
too bad :\

can you think of a way to "remember" the last page the user have been to, for loading it next time he uses this page?

Thanks

cyber11
Nov 24th, 2006, 07:51 PM
too bad :\

can you think of a way to "remember" the last page the user have been to, for loading it next time he uses this page?

Thanks

Try server side in PHP there is getenv("HTTP_REFERER")

In Perl $ENV{'REMOTE_ADDR'} or HTTP_REFERER

ShMiL
Nov 24th, 2006, 09:07 PM
server variables (like REFERER) returns the origin of arrival from a dynamic page.

how do you recon I can use it to find out what's going on in one of the frames?!

I'm afraid it's not such a good idea.