2

I want to implement the back button functionality so that upon clicking that the previous visited page has to be presented without reloading it, but to be seen as it was updated/visited before.

I have implemented it as

<input type="button" name="back" value="Back" onClick="history.go(-1)" />

but its trying to load the page.

Is it possible to implement back button functionality without loading the page?

Techie
  • 1,611
  • 3
  • 15
  • 24

1 Answers1

1

No, isn't any trick to get URL of history object - source: get full url history using javascript

You can instead set the history on cookies( i know , i know ), a website (preferably a part of them, such as body) loads with ajax.

<input type="button" name="back" value="Back" />

Something like:

   $( "input[name=back]" ).click( function(){
            $( "body" ).load( urlFromYourCookieHistoryStack + " body" );

   });

History will be available throught on website which you defining it. Read about jQuery load method => http://api.jquery.com/load/

Using jQuery cookie plugin shouldn't be troublesome

Community
  • 1
  • 1
abuduba
  • 4,986
  • 7
  • 26
  • 43
  • Hi thanks for the response and sorry to say that I dont want to implement jquery only for this functionality in my code. – Techie Dec 29 '11 at 14:38
  • Everything that is written in jQuery can be without it. Load method => Write a simple functionality of ajax ( read about xmlHttpRequest object). When you download the file using ajax put its contents to the newly created e.g. HTMLDivElement which is not appended to document. `var div = document.createElement("div"); div.innerHTML = responseFromAjax; document.body.innerHTML = div.getElementByTagName("body").innerHTML` There are a lot of code on the internet for ajax and cookies. – abuduba Dec 29 '11 at 14:44