?
Solved

Navigating to Document Referrer even if window.location used previously

Posted on 2003-12-12
4
Medium Priority
?
652 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

770 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