Click to See Complete Forum and Search --> : how to access previous page's href in both IE and netscape


webrunner
03-04-2003, 02:11 PM
Hi, I want to jump into a frames page from a hyperlink and dynamically load the url of the previous page into the left frame. I know there is a way to grab the previous pages url but I having a hard time finding it. could someone help with this. Basically I want to be able to do something similar to using the history.previous in netscape.

gil davis
03-04-2003, 03:09 PM
The history object is a secure data space. You cannot access the actual URL using javascript, unless you have a security certificate and the client agrees to your request for expanded privileges.

Your only chance is

document.referrer

but if it is in a different domain, you will get null.

Other than that, if it is your page, you can pass the page name in the URL and capture it in the next document.

webrunner
03-04-2003, 04:02 PM
Good suggestions. I am currently trying to pass it but I am having trouble. I try to concatenate the url then send using location.href and it works but it tries to open another window because I am using onclick, I try href=javascript:callhelp() but it gives me an error. Anyway the big problem is receiving, when I try to use location.href.split() it does not seem to receive it. I am probably doing something majorly wrong here is my code.
This is a frames page and the object is to get the passed parameter to be used to update the current frame and reference the previous page.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<SCRIPT language=JavaScript1.2>
function callPreviousPage() {
urlquery=location.href.split("?");
if(urlquery[1]) {
document.encode(urlquery[1]);
}
parent.realchoices.location=urlquery[1];
void 0;
}

</SCRIPT>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body target="realchoices" onLoad="javascript:callPreviousPage()">

</body>
</html>

webrunner
03-04-2003, 06:10 PM
an update on the situation. I think document.referrer will work for my needs and it works in both browsers. i don't think i will ever need to call the frames outside of my domain so i think it won't be a problem. it appears to work thanks.

gil davis
03-05-2003, 05:39 AM
Just an FYI, but the stuff you pass in the URL is accessed using

window.location.search