Solved

Navigating to Document Referrer even if window.location used previously

Posted on 2003-12-12
4
640 Views
Last Modified: 2008-02-01
Hi

I need to create a back button which goes to the previous page however history.go dosnt work as I use forms submitting to invisible frames so it sends them back instead of the main screen.  Document referrer was my next thought but it only works if the current page was loaded from an html <a href> and not with a javascript onclick="window.location='';"

Can I get this information when window.location navigation has been used ?

Thanks
0
Comment
Question by:rfila
4 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9929151
If you can use server side code, create your own back button that will post the values back to the previous page. You can then repopulate your fields using the request object.

Fritz the Blank
0
 
LVL 25

Expert Comment

by:devic
ID: 9930567
hi rfila,

all works fine, where is the problem?


===============beginn page1.html==============

<a href=page2.html class=text>click here page2.html</a>

===============end page1.html================





===============beginn page2.html==============

<script>
function runit()
{
      history.back();
}
</script>
<button onclick=runit()>back go back</button>

<form action=http://www.google.com/search target=hidden_iframe>
      <input type=text name=q value=hurra>
      <input type=submit>
</form>
is no hidden for testing:
<iframe name=hidden_iframe></iframe>

===============end page2.html================
0
 
LVL 15

Accepted Solution

by:
JakobA earned 500 total points
ID: 9931989
No.
When you swithc to a new page using javascript, no value is set into document.referrer.

the easiest way around this is to use an invisible link:

at the top of your <body  section:
<body ... >
    <a href=""></a>

then whereever you have a line like
     self.location.href = "newpage.html";
you write instead:
     document.links[0].href = "newpage.html"; document.links[0].click();

it is now the link that sends you on and the referrer property is set when you arrive at the new page.

regards JakobA
0
 
LVL 7

Expert Comment

by:gam3r_3xtr3m3
ID: 9933892
maybe place it into a query string:

main.html
------------
<body onLoad="document.frm1.urlback.value=escape(window.location)">
<form name="frm1" action="next.html" method="get">
<input type="text" name="text1" /><input type="submit" />
<input type="hidden" name="urlback" />
</form>

next.html
-----------
<input type="button" value="Go Back!" onClick="window.location=unescape(window.location.href.split('urlback')[1].split('=')[1]));" />
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now