Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

soni lal
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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

Suppose I am in page having some href which is taking me to new page e.g

Now in page : 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
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ->
Every plan is a little cooler if you have a blimp. And a tiny ad.
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic