Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Navigating to Document Referrer even if window.location used previously

Posted on 2003-12-12
4
Medium Priority
?
659 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

636 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