Hello all!
I am using a little piece of code in a report I'm generating (LogiXML). It is a "back" button that takes the user back to the previous page.. It does not however, use any form of a history, back, location javascript code. It just uses a plain old link directly to the page prior. I am rather partial to the history.back statement though because it always seemed much faster. (Possibly the page already being loaded in the cache, I'm not sure.) I'd like to make though, that the history.back() command will always take me to the page it should be going to. So if the history.back.value (in theory) is equal to "load.htm" (the page it should be going to) then proceed to history.back(), else, window.location = "load.htm";... Could someone instruct me on the correct syntax for this? Thank you very much!

Recommended Answers

All 2 Replies

I'd like to make though, that the history.back() command will always take me to the page it should be going to

So it sounds like you are familiar with the history object in JavaScript. Yes, executing this method would take the user to the previous page.

Example code:

<script type="text/javascript">
  function prevPage(){
    window.history.back();
  }
</script>

<a href="javascript:void(0);" 
    onclick="prevPage()">-- Previous Page --</a>

Right, I just want to be able to check the location of that page (i.e. the url) and make sure it is the page I intend for it to go. I did not create this page so I am not sure if the page where I came from previously will be the page where everyone comes previously. I need to make sure that the value for the history.back() function will take the user to the create url. If not, I want it to resort to the (slower) window.location function which will guarentee the return to the proper page. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.