ralatorre
ralatorre

Reputation: 22

Back button not working after reloading DIV

I am currently using this code for a website, when you click a link the central Div is refreshed, thus saving some bandwidth. The code works like a charm, the only problem is that when I click the back button it takes me out of the page, as the browser is only registering one visit to the site. Any workaround for this? JS:

<script type="text/javascript">
var ajaxdestination="";

function getdata(what,where) { 
 try {
   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
        new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (e) {
 }

 document.getElementById(where).innerHTML ="<center><br><br><img id='loader'      src='carga.png'></center>";
 ajaxdestination=where;
 xmlhttp.onreadystatechange = triggered;
 xmlhttp.open("GET", what);
 xmlhttp.send(null);
 return false;
}

function triggered() {
      if (xmlhttp.readyState == 4) if (xmlhttp.status == 200) 
    document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;
}
</script>

And my links look like this:

<a class="active" href="javascript:void(0)" onclick="getdata('pag/identidad.php', 'container');">

EDIT: I am talking about the browser's back button :)

Upvotes: 0

Views: 137

Answers (2)

Exlord
Exlord

Reputation: 5371

you need to use jquery address plugin http://www.asual.com/jquery/address/

Upvotes: 0

Karthick Kumar
Karthick Kumar

Reputation: 2361

where is your back button .. it is in your website or it is browser back button .what you want to do when you click back button , when you click back button in browser it will leave you from the current page to last visited page .

Upvotes: 2

Related Questions