File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes How to get the url of previous page on click of browser back button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to get the url of previous page on click of browser back button" Watch "How to get the url of previous page on click of browser back button" New topic
Author

How to get the url of previous page on click of browser back button

soni lal
Greenhorn

Joined: Jan 31, 2011
Posts: 29
Hi All,

I need to get the url from which the browser back button has been clicked

Suppose I am in page http://jchou.apple.com/kb/index?page=search&q=ipod&src=support_site.kbase.search.advanced having some href which is taking me to new page e.g http://jchou.apple.com/kb/HT1201

Now in page :http://jchou.apple.com/kb/HT1201 I clicked browser back button and came to previous page.

Here I have to get the information that from which page browser back button has been clicked.
I tried to use document.referrer but I didn't get the url of the page (where browser back button is clicked).

Please help me.

Thanks in advance.
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

I assume that the webpages you have mentioned in questions are your applications pages ? and if not I assume they are just examples, and if examples then you have your own webpages in which you are trying to control the "back" button of the browser. If yes then look at the below link, it has a nice example on controling the browser back button. I tried it in IE and it works like a charm. But you have to test it for other browsers
WARNING - its messy.. and its not a good design to control any browser related functionality, avoid if you can

Link using javascript.-> webpage

you can modify the above code to show your browser's url like ->


Time is what we want the most, but what we use the worst. -- William Penn
 
wood burning stoves
 
subject: How to get the url of previous page on click of browser back button